Author Topic: Error: out of memory  (Read 12103 times)

Offline Melssj5

  • double
  • *****
  • Posts: 724
    • View Profile
Error: out of memory
« on: March 22, 2006, 03:29:37 am »
Hi, I am getting this error all the time, my game used to compile well, but one day just this began to appear.

I have not added new objects. It appears on the first part of th program when loading the textures. I also tried to increased the asigned memory to java but nothing seems to work.
Nada por ahora

Offline manumoi

  • long
  • ***
  • Posts: 121
    • View Profile
    • http://www.iro.umontreal.ca/~blanchae
Error: out of memory
« Reply #1 on: March 22, 2006, 07:54:29 am »
Hello,

Try using the option -Xmx of java like :

java -Xmx256m Bob  // if your main method is in Bob.class

the value after -Xmx refers to the size of memory that will be allocated to the  virtual machine process (here 256 meg....  but you can also specify a number of meg without using the suffixe m like java -Xmx100000000 Bob).

Manu

PS: of course, if needed don t forget other options like -cp or -D

Offline Melssj5

  • double
  • *****
  • Posts: 724
    • View Profile
Error: out of memory
« Reply #2 on: March 22, 2006, 01:58:43 pm »
I did it, but the error is still there, it appears when loading the 10% of the game, it used to load all the game without problem.
Nada por ahora

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Error: out of memory
« Reply #3 on: March 22, 2006, 05:50:40 pm »
Maybe posting your actual call to java would help...

Offline Melssj5

  • double
  • *****
  • Posts: 724
    • View Profile
Error: out of memory
« Reply #4 on: March 22, 2006, 06:13:55 pm »
Do you mean how do I call to the program?, well, I just run it on the ide. from outside the ide just java package.class

I tried using that commands to increased the asigned memory and it just continue a little bit more but taking almost 15 minutes, and then the error appears again. I have not changed anything in my code to get this error, it just appeared suddenly.
Nada por ahora

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Error: out of memory
« Reply #5 on: March 22, 2006, 06:19:00 pm »
So when running it with java -Xmx256m <yourfile>, it bombs out after 15 minutes or it takes 15min to load??
If the former is the case, then you've most likely created a memory leak somewhere in your code but it's hard to tell from here.

Offline Melssj5

  • double
  • *****
  • Posts: 724
    • View Profile
Error: out of memory
« Reply #6 on: March 22, 2006, 06:24:11 pm »
Yes, I was thinking it may be somethig about my code, but the strange thing is that is the same code that used to compile well, I have not changed anything.
Nada por ahora

Offline manumoi

  • long
  • ***
  • Posts: 121
    • View Profile
    • http://www.iro.umontreal.ca/~blanchae
Error: out of memory
« Reply #7 on: March 22, 2006, 06:39:39 pm »
Hello Melssj,

Are you sure you dont  create more than one version of the same object? I mean the garbage collector works with weak pointers to determine which memory for which object can be reallocated. If there are no more reference on an object, the value of the pointer for this object is changer and this object will be put in the list of the garbage collector but if there is at least one reference (for example if you keep it in a collection), the garbage collector will never be able to liberate the memory.

I think it must be something like that... but as Egon notices it s very difficult to determine where this error is provoked.

Manu

PS : maybe you can look in your code where you call "new" and see if it s really necessary.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Error: out of memory
« Reply #8 on: March 22, 2006, 06:41:19 pm »
Something has to be different then...code doesn't degrade over time. Try to add -Xrunhprof to your call like so:

java -Xrunhprof:file=prof.txt,heap=sites -Xmx256m ...

You'll get a file called prof.txt containing profiling data. At the end of the file, you'll find some stats about object/memory usage. The trace number in this corresponds to the traces earlier in the file, so it should be possible to see where you are creating a lot of objects.

Hope this helps.

Offline Melssj5

  • double
  • *****
  • Posts: 724
    • View Profile
Error: out of memory
« Reply #9 on: March 22, 2006, 06:49:18 pm »
For me the text is like chinesse, I can imagine that the variables are not being free after using them.!!!

SITES BEGIN (ordered by live bytes) Wed Mar 22 12:35:16 2006
          percent          live          alloc'ed  stack class
 rank   self  accum     bytes objs     bytes  objs trace name
    1  4.09%  4.09%   9600048    1   9600048     1 304076 float[]
    2  4.09%  8.18%   9600048    1   9600048     1 304055 int[]
    3  4.09% 12.27%   9600048    1   9600048     1 304075 float[]
    4  4.09% 16.36%   9600048    1   9600048     1 304074 float[]
    5  4.09% 20.45%   9600048    1   9600048     1 304073 float[]
    6  4.09% 24.54%   9600048    1   9600048     1 304056 float[]
    7  4.09% 28.63%   9600048    1   9600048     1 304072 float[]
    8  4.09% 32.72%   9600048    1   9600048     1 304071 float[]
    9  4.09% 36.81%   9600048    1   9600048     1 304070 float[]
   10  4.09% 40.90%   9600048    1   9600048     1 304069 float[]
   11  4.09% 44.99%   9600048    1   9600048     1 304068 float[]
   12  4.09% 49.08%   9600048    1   9600048     1 304067 float[]
   13  4.09% 53.17%   9600048    1   9600048     1 304066 float[]
   14  4.09% 57.26%   9600048    1   9600048     1 304065 float[]
   15  4.09% 61.35%   9600048    1   9600048     1 304064 float[]
   16  4.09% 65.44%   9600048    1   9600048     1 304063 int[]
   17  4.09% 69.53%   9600048    1   9600048     1 304057 float[]
   18  4.09% 73.62%   9600048    1   9600048     1 304058 float[]
   19  4.09% 77.71%   9600048    1   9600048     1 304059 float[]
   20  4.09% 81.80%   9600048    1   9600048     1 304060 float[]
   21  4.09% 85.89%   9600048    1   9600048     1 304061 float[]
   22  1.57% 87.46%   3683536   13   3683536    13 302620 int[]
   23  1.36% 88.82%   3200024    1   3200024     1 304054 int[][]
   24  1.36% 90.18%   3200016    1   3200016     1 304010 com.threed.jpct.Object3D[]
   25  1.36% 91.55%   3200016    1   3200016     1 304012 int[]
   26  1.36% 92.91%   3200016    1   3200016     1 304014 float[]
   27  1.36% 94.27%   3200016    1   3200016     1 304015 int[]
   28  1.36% 95.64%   3200016    1   3200016     1 304016 int[]
   29  1.36% 97.00%   3200016    1   3200016     1 304009 com.threed.jpct.Object3D[]
   30  1.36% 98.36%   3200016    1   3200016     1 304011 int[]
   31  1.36% 99.73%   3200016    1   3200016     1 304013 int[]
   32  0.11% 99.84%    263184    1    263184     1 302033 int[]
SITES END :oops:
Nada por ahora

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Error: out of memory
« Reply #10 on: March 22, 2006, 07:04:33 pm »
Are you be any chance using veeeeery large textures? (8129*8192 or something...?)

Offline Melssj5

  • double
  • *****
  • Posts: 724
    • View Profile
Error: out of memory
« Reply #11 on: March 22, 2006, 07:35:37 pm »
no, my textures are very small, 256x256 and the highest if of 736x428
Nada por ahora

Offline Melssj5

  • double
  • *****
  • Posts: 724
    • View Profile
Error: out of memory
« Reply #12 on: March 25, 2006, 11:10:39 am »
SO?  :?
Nada por ahora

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Error: out of memory
« Reply #13 on: March 25, 2006, 11:16:07 am »
No idea! If it's a jPCT problem (which i doubt, but you never know...), then i can't reproduce it to the slightest. If it's something in your code...how should we know!? Maybe you can try to build a minimal test case. I still haven't fully understood if this happens on start up or after the application has been running for some time!?

Offline Melssj5

  • double
  • *****
  • Posts: 724
    • View Profile
Error: out of memory
« Reply #14 on: March 25, 2006, 11:20:58 am »
I happens when trying to build a world, my app uses 4 worlds, fater loading the textures my program began to load the worlds, and the error appear when trying to load the first world.

As I said before I used to run it well, now it stop on this error almost when beginning to load everything.

I have 512 MB of ram. I can perfectly run other jpct app I have done. I better review my code again. I am thinking that the evil lives ibside my PC, always happens something when doing important projects.
Nada por ahora