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.
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
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.
Maybe posting your actual call to java would help...
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.
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.
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.
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.
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.
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:
Are you be any chance using veeeeery large textures? (8129*8192 or something...?)
no, my textures are very small, 256x256 and the highest if of 736x428
SO? :?
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!?
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.
Try this to narrow it down:
Start your app with "-Xms256m -Xmx256m" to set initial and max memory to the same value, so that no further memory allocation happens while running the program. Then call this method before and after doing...whatever...to see if this "whatever" maybe causes the problem.
public void memUsed() {
Runtime rt=Runtime.getRuntime();
System.out.println("Memory used: "+(rt.totalMemory()-rt.freeMemory()));
}
hello, maybe you can show us your JPCT code if it s not copyrighted (or some parts only if too big).
Currently i have no clue on your problem.
Manu
It happens when creating a new World. I mean when calling to the constructor.
Memory used: 6209920
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
I have not posted in many time because I have had no time.
ok ok, I have found the problem that delayed me 3 weeks. Just was for a high value for Config.maxPolysVisible.
Is there a way to avoid the render dissapearing when its far without using Config.maxPolysVisible.
No, but may i ask which value you've assigned to Config.maxPolysVisible? I can't imagine a value that causes an out of memory and that is still reasonable to be managed by the engine. If you are using multiple worlds, you can give Config.shareVisibilityList a try, but be aware that this isn't always possible.
Hello Mellsj
here is what i do to avoid rendering every polygons in my scene, I put the fog at a distance smaller than the farPlane value,
My maxPolysVisible is 50000 and it works just fine. But as Egon said, i m surprised that your problem comes from this point
private void setupFog(){
theWorld.setFogging(World.FOGGING_ENABLED);
theWorld.setFogParameters(1000,0, 0, 0);
Config.farPlane = 1020;
}
I used a very high value, because I tried to use "real size", I mean in relative units, so the crafts are large and the maps are huge, I better use a scale on all of them.