View Single Post
Old March 18th, 2003, 11:54 AM     #6 (permalink)
DJDaveMark
Member
 
DJDaveMark's Avatar
 
Join Date: Feb 2003
Location: France
Posts: 55
Re: copying VERY large arrays with JAVA

Quote:
Originally posted by zskillz
I am working with a VERY VERY large data set (345600 lines w/ x,y,z coordinates on each line). I have 2 arrays of this size that are created by reading in a file containing them.

here's the question though. .... once i create the 2 objects (1 position, 1 velocity) I don't need the static arrays that are taking up space in the main method. can I just delete them to free up the space

Hey, I'm new to posting here which explains why this
is so late but i just wanted to clear something up.

In Java you can't delete objects that have been created
or directly free the resources that they're using.
Object's are eligible for garbage collection when there's
no more references to that object. You can have multiple
references to the same object, so all references to an
object must be dropped before Garbage Collection could
occur.

You can however guide the JVM into Garbage Collecting
objects that are no longer needed.

An example....

int anArray[] = new int[345600]; //a big object
int anArray = null;       &nb sp;      //a big object with no references
System.gc();      &n bsp;       &nbs p;      //a suggestion to the JVM to garbage collect


The call to System.gc is only a suggestion and the JVM
may well ignore your request, but if you've created, used
and set to null all references for a big resource hogging
object then it may well be Garbage Collected.

DaveMark

-------------------------------------
Imagination is more important than knowledge.
-- Albert Einstein
DJDaveMark is offline   Reply With Quote