Hi guys i am having a memory problem. this is the code: Runtime runtime = Runtime.getRuntime(); public static final int IMAGE_MEMORY_NEEDED = 3 * 1024 * 1024; int  tmpArray = null; tmpArray = new int[IMAGE_MEMORY_NEEDED]; tmpArray = 1; tmpArray[IMAGE_MEMORY_NEEDED - 1] = 1; tmpArray = null; tmpArray = new int; runtime.gc(); Thread.yield(); ... i need to free the memory, but it nothing is working, it's not freeing the memory!? why is that, the gc is not collecting any ideas!? Thanks, omar
Note that Sun's JVMs never return memory to the OS; free memory is returned to the Java heap, but your "task manager" or other OS-dependent tool will still show the memory being allocated to the process.
No. The heap of Sun's JVMs will grow, but won't shrink, in size. If this is important for your application, there might be other (commercial) JVMs that don't have this property; you'd have to do some Googling and check it out.