Results 1 to 14 of 14
  1. #1
    elect is offline Member
    Join Date
    Dec 2011
    Posts
    4
    Rep Power
    0

    Default Over a specific valuet: java.lang.OutOfMemoryError

    Hi all,

    Here the code

    Java Code:
    vertexData = GLBuffers.newDirectFloatBuffer(triangleNumber*3*3);
          for(int i=0; i<triangleNumber; i++) {
              Triangle tmp = triangleArray.get(i);
              vertexData.put(new float[]{tmp.x1/12000.0f, tmp.y1/12000.0f, tmp.z1/12000.0f, 
                                         tmp.x2/12000.0f, tmp.y2/12000.0f, tmp.z2/12000.0f, 
                                         tmp.x3/12000.0f, tmp.y3/12000.0f, tmp.z3/12000.0f  });
    The problem arises when triangleNumber is bigger than about 2 milions

    It seems that the default size is around 64 MB (2M = 68MB)

    -XX:MaxDirectMemorySize=256M didnt help >.>

    I would need, lets say, to allocate up to 10 milions of triangles (then 10 M *3*3) to push them later in the gpu framebuffer, but 5 can be already a nice solution

    Any idea?

  2. #2
    quad64bit's Avatar
    quad64bit is offline Moderator
    Join Date
    Jul 2009
    Location
    VA
    Posts
    1,323
    Rep Power
    6

    Default Re: Over a specific valuet: java.lang.OutOfMemoryError

    The java.lang.OutOfMemoryError is pretty generic, have you tried just increasing the VM memory allocation?

    -Xmx512m -Xms512m

    Something like that?

  3. #3
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,450
    Rep Power
    18

    Default Re: Over a specific valuet: java.lang.OutOfMemoryError

    From the docs for -XX:MaxDirectMemorySize:
    This option specifies the maximum total size of java.nio (New I/O package) direct buffer allocations.

    Not really what you want...
    quad64bit has given you the proper switch (-Xmx).

  4. #4
    elect is offline Member
    Join Date
    Dec 2011
    Posts
    4
    Rep Power
    0

    Default Re: Over a specific valuet: java.lang.OutOfMemoryError

    Quote Originally Posted by quad64bit View Post
    The java.lang.OutOfMemoryError is pretty generic, have you tried just increasing the VM memory allocation?

    -Xmx512m -Xms512m

    Something like that?
    I had a java heap overflow and I solved with the first argument that you mention

    Right now my arguments are the following, but unfortunately the second one seems to be superfluous

    -Xmx1500m -XX:MaxDirectMemorySize=256M


    Quote Originally Posted by Tolls View Post
    From the docs for -XX:MaxDirectMemorySize:
    This option specifies the maximum total size of java.nio (New I/O package) direct buffer allocations.

    Not really what you want...
    quad64bit has given you the proper switch (-Xmx).
    The crash in the console points at the part of code that I illustrated in the first post. And it happens only when triangleNumber is about bigger than 2M so I guess it should be something related to the buffer allocation..no?
    Last edited by elect; 12-23-2011 at 10:32 AM.

  5. #5
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,450
    Rep Power
    18

    Default Re: Over a specific valuet: java.lang.OutOfMemoryError

    NIO is the New Input/Output package.
    It's entirely related to IO...nothing to do with general memory management, or OOM exceptions.
    You are not doing any IO there (or using that package) so that parameter is irrelevant.

  6. #6
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,001
    Blog Entries
    7
    Rep Power
    20

    Default Re: Over a specific valuet: java.lang.OutOfMemoryError

    Quote Originally Posted by Tolls View Post
    NIO is the New Input/Output package.
    It's entirely related to IO...nothing to do with general memory management, or OOM exceptions.
    Well, sort of; the NIO package uses the system calls mmap, munmap and compadres (for mapping files to (virtual) memory) and they can take up quite some memory in the process space. I don't know if that memory resides in Java's heap space or not ... (I think it does)

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  7. #7
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,450
    Rep Power
    18

    Default Re: Over a specific valuet: java.lang.OutOfMemoryError

    Quote Originally Posted by JosAH View Post
    Well, sort of; the NIO package uses the system calls mmap, munmap and compadres (for mapping files to (virtual) memory) and they can take up quite some memory in the process space. I don't know if that memory resides in Java's heap space or not ... (I think it does)

    kind regards,

    Jos
    But is the OP using any NIO stuff?
    There's nothing in that post to suggest it...and if it is the case then maybe it might have been an idea to point it out?

    In any case I'd have thought the memory error would have been different than a base heap one if it were to do with NIO.

  8. #8
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,001
    Blog Entries
    7
    Rep Power
    20

    Default Re: Over a specific valuet: java.lang.OutOfMemoryError

    Quote Originally Posted by Tolls View Post
    But is the OP using any NIO stuff?
    There's nothing in that post to suggest it...and if it is the case then maybe it might have been an idea to point it out?

    In any case I'd have thought the memory error would have been different than a base heap one if it were to do with NIO.
    All true; I was just thinking in a nuts and bolts kindof way. NIO stuff can take up a lot of memory, but the OP wasn't using any NIO classes, so I'll keep my mouth shut and think my low level things again ;-)

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  9. #9
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,450
    Rep Power
    18

    Default Re: Over a specific valuet: java.lang.OutOfMemoryError

    Know your place...

  10. #10
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,001
    Blog Entries
    7
    Rep Power
    20

    Default Re: Over a specific valuet: java.lang.OutOfMemoryError

    Quote Originally Posted by Tolls View Post
    Know your place...
    Aye aye 'squire, can I go back to my corner and do my low level nuts and bolts deeds now, please?

    kindest regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  11. #11
    quad64bit's Avatar
    quad64bit is offline Moderator
    Join Date
    Jul 2009
    Location
    VA
    Posts
    1,323
    Rep Power
    6

    Default Re: Over a specific valuet: java.lang.OutOfMemoryError

    I've also had strange memory errors in the past with large web apps. In that case, adjusting the perm size helped:

    -XX:MaxPermSize=256m -XX:PermSize=128m

    FYI the second argument isn't required, but I like to set minimums for certain contexts!

  12. #12
    elect is offline Member
    Join Date
    Dec 2011
    Posts
    4
    Rep Power
    0

    Default Re: Over a specific valuet: java.lang.OutOfMemoryError

    Quote Originally Posted by quad64bit View Post
    I've also had strange memory errors in the past with large web apps. In that case, adjusting the perm size helped:

    -XX:MaxPermSize=256m -XX:PermSize=128m

    FYI the second argument isn't required, but I like to set minimums for certain contexts!
    Unfortunately:

    Error occurred during initialization of VM
    Error: Could not create the Java Virtual Machine.
    Could not reserve enough space for object heap
    Error: A fatal exception has occurred. Program will exit.
    Java Result: 1

  13. #13
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,450
    Rep Power
    18

    Default Re: Over a specific valuet: java.lang.OutOfMemoryError

    Quote Originally Posted by quad64bit View Post
    I've also had strange memory errors in the past with large web apps. In that case, adjusting the perm size helped:

    -XX:MaxPermSize=256m -XX:PermSize=128m

    FYI the second argument isn't required, but I like to set minimums for certain contexts!
    That would give a different exception message.

    Quote Originally Posted by elect View Post
    Unfortunately:
    In which case you need to give it less memory...you are either exceeding your system or, more likely, the limitation of a Java 32 bit JVM (1.5 G?).

  14. #14
    elect is offline Member
    Join Date
    Dec 2011
    Posts
    4
    Rep Power
    0

    Default Re: Over a specific valuet: java.lang.OutOfMemoryError

    Quote Originally Posted by Tolls View Post
    That would give a different exception message.



    In which case you need to give it less memory...you are either exceeding your system or, more likely, the limitation of a Java 32 bit JVM (1.5 G?).

    Solved by switching from xp 32b to 7 64b :)

Similar Threads

  1. java.lang.OutOfMemoryError..Help me
    By kathir0301 in forum Advanced Java
    Replies: 1
    Last Post: 11-22-2010, 08:44 AM
  2. Ant fileset java.lang.OutOfMemoryError
    By 1inmillion in forum Advanced Java
    Replies: 0
    Last Post: 12-23-2008, 04:27 PM
  3. java.lang.OutOfMemoryError
    By new_2_java in forum New To Java
    Replies: 2
    Last Post: 11-01-2008, 05:12 AM
  4. java.lang.OutOfMemoryError
    By vidhya.sk in forum New To Java
    Replies: 2
    Last Post: 09-18-2008, 12:21 PM
  5. java.lang.OutOfMemoryError in a web service client
    By elchape in forum Advanced Java
    Replies: 4
    Last Post: 06-28-2008, 05:21 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •