example of excessive memory use (shootout)

Discussion in 'Java' started by fft1976, Jun 30, 2009.

  1. fft1976

    fft1976 Guest

    fft1976, Jun 30, 2009
    #1
    1. Advertising

  2. On Jul 1, 2:40 am, fft1976 <> wrote:
    > Why is Java using 15MB here?


    Is this a troll?

    >..The problem requires allocating a
    > negligible amount of memory:
    >
    > http://shootout.alioth.debian.org/u64/benchmark.php?test=nbody〈=j...


    (shrugs) If you want to shrink everything down
    to the absolute minimum, code in machine language.
    Java is not really designed for 'tiny memory' or
    'quick start up and toss away' apps.

    --
    Andrew T.
    pscodo.org
     
    Andrew Thompson, Jun 30, 2009
    #2
    1. Advertising

  3. fft1976

    Lew Guest

    On Jun 30, 12:40 pm, fft1976 <> wrote:
    > Why is Java using 15MB here? The problem requires allocating a
    > negligible amount of memory:
    >
    > http://shootout.alioth.debian.org/u64/benchmark.php?test=nbody〈=j...


    What is meant here by "using 15MB"? Total for the JVM? Heap?
    Classes plus heap?

    If you're comparing to another language such as C, are you accounting
    for their parts of system memory that correspond to the bytecode
    interpreter, the support classes and the HotSpot compiler?

    How much of the reported Java usage is to run the program itself, and
    how much just to run Java?

    Don't compare apples to bicycles.

    --
    Lew
    Mmm! Bicycle pie!
     
    Lew, Jun 30, 2009
    #3
  4. fft1976

    Lord Zoltar Guest

    Lord Zoltar, Jun 30, 2009
    #4
  5. fft1976

    fft1976 Guest

    On Jun 30, 10:21 am, Andrew Thompson <> wrote:
    > On Jul 1, 2:40 am, fft1976 <> wrote:
    >
    > > Why is Java using 15MB here?

    >
    > Is this a troll?


    No. Can you explain why you think it might be? Is this a sensitive
    topic?

    > >..The problem requires allocating a
    > > negligible amount of memory:

    >
    > >http://shootout.alioth.debian.org/u64/benchmark.php?test=nbody〈=j...

    >
    > (shrugs) If you want to shrink everything down
    > to the absolute minimum, code in machine language.


    I was under the impression that JVM had a fixed memory overhead per
    process, and maybe a small (2-fold or so?) overhead for the data
    structures.

    Some other shootout entries use less than 1MB, so the fixed overhead
    should be small. (The linked entry uses very few libraries, by the
    way).

    The data structures needed here are perhaps 0.1KB in size. So, again,
    why 15MB and not 1MB or so?

    And would the memory usage go up to 150MB if the data structures were
    ten times larger?
     
    fft1976, Jul 1, 2009
    #5
  6. fft1976 wrote:
    > On Jun 30, 10:21 am, Andrew Thompson <> wrote:
    >> On Jul 1, 2:40 am, fft1976 <> wrote:
    >>
    >>> Why is Java using 15MB here?

    >> Is this a troll?

    >
    > No. Can you explain why you think it might be? Is this a sensitive
    > topic?


    The shootout is frequently used by trolls.

    >>> ..The problem requires allocating a
    >>> negligible amount of memory:
    >>> http://shootout.alioth.debian.org/u64/benchmark.php?test=nbody〈=j...

    >> (shrugs) If you want to shrink everything down
    >> to the absolute minimum, code in machine language.

    >
    > I was under the impression that JVM had a fixed memory overhead per
    > process, and maybe a small (2-fold or so?) overhead for the data
    > structures.
    >
    > Some other shootout entries use less than 1MB, so the fixed overhead
    > should be small. (The linked entry uses very few libraries, by the
    > way).
    >
    > The data structures needed here are perhaps 0.1KB in size. So, again,
    > why 15MB and not 1MB or so?
    >
    > And would the memory usage go up to 150MB if the data structures were
    > ten times larger?


    Why don't you just test yourself?

    Arne
     
    Arne Vajhøj, Jul 1, 2009
    #6
  7. fft1976

    Roedy Green Guest

    On Tue, 30 Jun 2009 09:40:50 -0700 (PDT), fft1976 <>
    wrote, quoted or indirectly quoted someone who said :

    >
    >
    >http://shootout.alioth.debian.org/u64/benchmark.php?test=nbody&lang=javasteady&id=2


    A few thoughts:

    public final class nbody should be public final class Nbody or NBody

    Did you mean for this code to be static init?

    public NBodySystem(){
    bodies = new Body[]{
    Body.sun(),
    Body.jupiter(),
    Body.saturn(),
    Body.uranus(),
    Body.neptune()
    };

    I suspect what you might have done is disappear up your own ass by
    recursively using new Body.

    You might just add a stack trace dump to the Body constructor and see
    if the behaviour is what you expected. See
    http://mindprod.com/jgloss/trace.html

    --
    Roedy Green Canadian Mind Products
    http://mindprod.com

    "Deer hunting would be fine sport, if only the deer had guns."
    ~ William S. Gilbert of Gilbert and Sullivan
     
    Roedy Green, Jul 1, 2009
    #7
  8. fft1976

    Lew Guest

    fft1976 wrote:
    >>> Why is Java using 15MB here?
    >>> ...The problem requires allocating a
    >>> negligible amount of memory:
    >>> http://shootout.alioth.debian.org/u64/benchmark.php?test=nbody〈=j...

    >> (shrugs) If you want to shrink everything down
    >> to the absolute minimum, code in machine language.

    >
    > I was under the impression that JVM had a fixed memory overhead per
    > process, and maybe a small (2-fold or so?) overhead for the data
    > structures.


    That's not how it works. You haven't answered my questions upthread, though.

    Java is a whole virtual computer inside the physical one. You have to have
    memory for the JVM itself, for the classes that it loads, many of which are
    needed no matter what programs it might run, for the various heap generations,
    and for the program itself.

    > Some other shootout entries use less than 1MB, so the fixed overhead
    > should be small. (The linked entry uses very few libraries, by the
    > way).


    Did those other entries count the memory they needed for the computer OS itself?

    > The data structures needed here are perhaps 0.1KB in size. So, again,
    > why 15MB and not 1MB or so?


    Again, as I hinted upthread and am now saying outright, that 15 MB might very
    well include overhead for the JVM itself. It has to load a whole bytecode
    interpreter, the Hotspot compiler, various heap structures and some
    fundamental classes before it can even begin to load the application.

    > And would the memory usage go up to 150MB if the data structures were
    > ten times larger?


    If my guesses have any bearing on reality, and I really don't know if they do
    with respect to this "shootout", then no. It'll go up to about 15.01 MB.

    How about you answer the questions I asked:
    > What is meant here by "using 15MB"? Total for the JVM? Heap?
    > Classes plus heap?


    Remember, don't compare apples to bicycles. I doubt very much the "shootout"
    is comparing just the memory used by Java for the application; most likely
    it's counting the whole overhead of loading the Java computer within the host
    computer.

    --
    Lew
     
    Lew, Jul 1, 2009
    #8
  9. fft1976 wrote:
    > On Jun 30, 10:21 am, Andrew Thompson <> wrote:
    >> On Jul 1, 2:40 am, fft1976 <> wrote:
    >>
    >>> Why is Java using 15MB here?

    >> Is this a troll?

    >
    > No. Can you explain why you think it might be? Is this a sensitive
    > topic?


    Posting a complaint about memory usage using a microbenchmark that
    probably has little bearing on real-world considerations.

    > I was under the impression that JVM had a fixed memory overhead per
    > process, and maybe a small (2-fold or so?) overhead for the data
    > structures.


    It depends on many factors. There is the overhead of the VM itself, plus
    the requisite set of Java classes (system loaders, object, arrays,
    probably I/O as well, etc.).

    > Some other shootout entries use less than 1MB, so the fixed overhead
    > should be small. (The linked entry uses very few libraries, by the
    > way).


    Do other entries start up their own interpreter? Probably not.

    > The data structures needed here are perhaps 0.1KB in size. So, again,
    > why 15MB and not 1MB or so?


    Because there's a lot more going on then you've cared to try to think about.

    > And would the memory usage go up to 150MB if the data structures were
    > ten times larger?


    Probably not. It depends on the data structures and how they scale with
    size.

    --
    Beware of bugs in the above code; I have only proved it correct, not
    tried it. -- Donald E. Knuth
     
    Joshua Cranmer, Jul 1, 2009
    #9
  10. fft1976

    fft1976 Guest

    On Jun 30, 7:12 pm, Lew <> wrote:

    > > What is meant here by "using 15MB"?  Total for the JVM?  Heap?
    > > Classes plus heap?


    It's my understanding that this is the total JVM usage at its peak.

    Sorry, it looks like I misread the data on the shootout web site. No
    other Java entries use significantly less than 15MB, so this one is
    actually one of the slimmest there. This makes more sense.
     
    fft1976, Jul 1, 2009
    #10
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Michael Chermside

    ConfigParser shootout, preliminary entry

    Michael Chermside, Oct 17, 2004, in forum: Python
    Replies:
    15
    Views:
    512
    WakeBdr
    Oct 20, 2004
  2. Carlos Ribeiro
    Replies:
    6
    Views:
    513
    Carlos Ribeiro
    Oct 21, 2004
  3. David Wilson
    Replies:
    13
    Views:
    540
    Paul Moore
    Oct 25, 2004
  4. Daniel N
    Replies:
    1
    Views:
    247
    Daniel N
    May 22, 2007
  5. Chris
    Replies:
    9
    Views:
    166
    Chris
    Nov 20, 2006
Loading...

Share This Page