How can I prevent memory leak after termination of application?

step 1.HashMap has data in it.

step 2.GC never think it as a garbage because HashMap has data.

step 3.Application is finished.

Memory still has HashMap data?

But right before the application is finished, I assigned HashMap = null.

Now, the application is terminated?

In this case, GC is also terminated, isn't it?

first of all, what I wrote above is true?

My goal is no memory leakage. When the application is over,

the HashMap data shouldn't be in memory.

How can I do that?

[547 byte] By [PaulSheldonII_Screena] at [2007-10-3 7:30:19]
# 1
You should do two things:- store in HashMap WeakReferences to objects (not References like you do now).- HashMap has problem with GC of keys on exit so use instead it WeakHashMap
vitallisa at 2007-7-15 2:29:49 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 2

thanks -

another question, right before the application ends,

even though I assigned null to all parameters,

what is happening exactly?

can GC clear off all the parameters with value of "null"

from the memory right before the end of appliation?

I really want to know what GC does right before the end of

termination. such as windowclosing() of application.

It would be really appreciated if you let me know.

or point out the place that describes.

Thank you -

PaulSheldonII_Screena at 2007-7-15 2:29:49 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 3

> an GC clear off all the parameters with value of

> "null" from the memory right before the end of appliation?

Why is this important to you?

When the application ends -- in other words, when the JVM shuts down -- every bit of memory that it consumed -- heap, stack code, whatever -- is returned to the OS. There isn't anything that Java can leak, because there isn't any JVM.

kdgregorya at 2007-7-15 2:29:49 > top of Java-index,Java HotSpot Virtual Machine,Specifications...