Re: Limit on maximum Array size..memory leaks?
Tuesday, August 13, 2002 09:14 AM
Firstly, you can allocate more memory for the JVM using '-Xms' and '-Xmx' command line options.
Secondly, what do you mean by 'everything created by "new" is automatically taken care of by the garbage collector'? The garbage collector will only free up the resources used by an object when it's no longer referenced. If you allocate an array of 5000 elements and fill each node of the array with an object then you have memory for the array itself (including placeholders for each node). You also have memory for each of those objects. If you want the garbage collector to remove an object before it goes out of scope then set all of its references to null. In this instance it would be mean setting a node in the array to null. You may also need to explictly invoke the garbage collector.