I ran the following code:
//======================================================= import java.io.*; class dup { public static void main(String args[]) { dupme ob = new dupme(0); }// end main() }// end class dup class dupme { public dupme(int me) { System.out.println("I am '" + me + "'!"); dupme ob = new dupme(me + 1); }// end interface dumpe(int me) }// end class dupme() //=======================================================
After 200,000 iterations and before 300,000 iterations, it simply dies. Spits out over 30kb of errors into a log file. Why does this happen? The equivallent code in perl...
#======================================================= package main; my $ob = dupme->new(0); package dupme; sub new { my $s = {}; bless $s; print "I am '$_[1]'!\n"; my $ob = $s->new($_[1]+1); return $s; }# end sub new #=======================================================
...ran faster (on my machine) and did not exit until 853865 iterations. I realize this is comparing apples to horses, but what does this tell me? Considering the way objects are started, exist and are destroyed in each VM is quite different, I realize this is the result of perhaps thousands of differences and 2 completely different development perspectives. On windows98, AMD500, 296Mb RAM, the java one ran only to just over 4000 iterations, while the perl version went beyond 2,000,000 iterations! I wonder why, if Java is supposed to have such slick garbage collection, does it have _any_ kind of problem?

In reply to Memory Use/Garbage Collection: Java vs Perl by c0d3cr33p

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.