Re: more than 10 seconds to allocate an array!

Discussion in 'Java' started by Thomas G. Marshall, Aug 28, 2003.

  1. Ahmed Moustafa <> horrified us with:

    > S.A. Samokhodkin wrote:
    >> Ahmed Moustafa writes:
    >>
    >>> On a SPARC E420, SunOS 5.8, JRE 1.4.1_02 and 1G RAM, it takes more
    >>> than 10 seconds to allocate an array as
    >>>
    >>> <code>
    >>> float[][] array = new float[10000][10000];
    >>> </code>
    >>>
    >>> Is not that *very* slow?
    >>>

    >>
    >> Supposedly because of the GC.
    >> Try -Xmx > 10^8*4 + O(10^8).

    >
    > I am already using -Xms1024m -Xmx1024m. And it is the only code in the
    > test program, so why could be the GC?


    It cannot be. The GC uses a mark and sweep algorthim that only impacts the
    system at gc time, and has no impact on system performance until that time,
    as far as I can tell.
    Thomas G. Marshall, Aug 28, 2003
    #1
    1. Advertising

  2. Thomas G. Marshall () wrote:
    : Ahmed Moustafa <> horrified us with:

    : > S.A. Samokhodkin wrote:
    : >> Supposedly because of the GC.
    : >> Try -Xmx > 10^8*4 + O(10^8).
    : >
    : > I am already using -Xms1024m -Xmx1024m. And it is the only code in the
    : > test program, so why could be the GC?

    : It cannot be. The GC uses a mark and sweep algorthim that only impacts the
    : system at gc time, and has no impact on system performance until that time,
    : as far as I can tell.

    Well what could be GC:ed? Quite a lot I think

    Here are the count of number of things that happen when I run java for
    _very_ simple things:
    robo@grunt:~/src/java$ java -Xrunjmp -version
    ....
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2-b28)
    ....
    jvm_shut_down.
    c_class_load: 304
    c_class_unload: 0
    c_object_alloc: 2633
    c_object_move: 0
    c_object_free: 0
    c_thread_start: 5 (one thread is for jmp, jvm only start 4)
    c_thread_end: 1
    c_method_entry: 590
    c_method_exit: 588
    ....

    Or what about this:
    robo@grunt:~/src/java$ java -Xrunjmp HelloWorld
    .....
    c_class_load: 338
    c_class_unload: 0
    c_object_alloc: 3380
    c_object_move: 0
    c_object_free: 0
    c_thread_start: 6 (one thread is for jmp...)
    c_thread_end: 2
    c_method_entry: 4301
    c_method_exit: 4301
    ....

    So by loading a program as simple as Hello world there are a lot of
    objects that can be GC:ed. Also note that if the jvm decides that it
    need more memory than is currently available on the heap it will try
    to perform a GC before growning the heap.

    Another interesting thing is that if I run
    java -Xms1024m -Xmx1024m -version
    it returns immediatly, clearly my OS (linux/2.4.x) has not given the
    java all it asks for (my machine only has 512M so I would notice a lot
    of disk activity if the jvm actually tried to write to that much
    memory).
    What OS are you running?
    Do you overcommit enabled? (linux has it as default)

    /robo
    Robert Olofsson, Aug 28, 2003
    #2
    1. Advertising

  3. > So by loading a program as simple as Hello world there are a lot of
    > objects that can be GC:ed. Also note that if the jvm decides that it
    > need more memory than is currently available on the heap it will try
    > to perform a GC before growning the heap.
    >
    > Another interesting thing is that if I run
    > java -Xms1024m -Xmx1024m -version
    > it returns immediatly, clearly my OS (linux/2.4.x) has not given the
    > java all it asks for (my machine only has 512M so I would notice a lot
    > of disk activity if the jvm actually tried to write to that much
    > memory).
    > What OS are you running?
    > Do you overcommit enabled? (linux has it as default)


    As I mentioned in my initial post, the machine is SPARC E420, SunOS 5.8,
    JRE 1.4.1_02 and 1G RAM, it is a big one.

    BTW, when I run the same on my Linux box (512M), i see kscand and kswapd
    very active and taking a lot of the CPU.
    Ahmed Moustafa, Aug 28, 2003
    #3
    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. Andy Flowers
    Replies:
    34
    Views:
    977
    Thomas G. Marshall
    Sep 6, 2003
  2. Jon Skeet
    Replies:
    6
    Views:
    380
    Ahmed Moustafa
    Aug 30, 2003
  3. Mark Thornton
    Replies:
    1
    Views:
    343
    Ahmed Moustafa
    Sep 1, 2003
  4. Alan Gifford
    Replies:
    4
    Views:
    383
    tom_usenet
    Oct 27, 2003
  5. Michael Tan
    Replies:
    32
    Views:
    940
    Ara.T.Howard
    Jul 21, 2005
Loading...

Share This Page