Also since plugin2 you can set the heap size for applets using Xmx or Xms parameters. By default each applet has a maximum heap size of 64mb, so if you want a small heap and you know your app won't go over it, you can set it as follows:
1 2
| <PARAM name="java_arguments" value="-Xmx16m"> |
Ok, I will try that in the next update to my game and see if it helps manage the memory better.
The Java Virtual Machine has a heap on which it allocates objects. The JVM starts out with a rather large heap, which is nearly empty. Once you start creating new objects, it will fill the heap. All this time the TaskManager will say your JVM takes 22mb, because it only sees the heap the JVM has created.
Besides that, yes, a typical Java application requires a bit more memory than your average C application. Nothing to worry about though, it's certainly not extreme. Every object has a 8 byte header, so you can do the math: an int is still 4 byte, and a float[100] is still 400 bytes plus object overhead. As the JVM doesn't free each object independently, you'll always have a fair amount of 'garbage' in the heap. Don't worry, the JVM can move objects around, 'compact' them, and shrink the heap, when it notices you released a lot of objects.
Just wondering cause if an applet used much memory for a simple display without the above info, as a consumer i would've freaked out.
Sincerely,
8BitOoze