wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Memory Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Memory" Watch "Memory" New topic
Author

Memory

pradeep chellappan
Greenhorn

Joined: Oct 20, 2005
Posts: 26
Hi all,

Can anyone please explain me what is the difference between cleaning up memory and releasing memory with a simple example.I hope that this doubt of mine will be useful for many!

Advance Thanks!
Pradeep
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38045
    
  22
Is there a difference? Cleaning up memory and releasing memory are things you don't do; Java does memory management automatically. So just forget about it.

There are a few instances where you might have to take precautions to prevent a memory leak, one being opening a file for reading. You have to put the .close() call inside a finally block to make absolutely sure that the file is closed, even if you have an Exception.

If you go to the Java website and put "memory management" into "search," you get this.
ak pillai
author
Ranch Hand

Joined: Feb 11, 2006
Posts: 288
I guess they mean the same thing. Unless some one can clarify otherwise.


The Java Garbage Collector runs in a low priority thread and it cannot be forced to execute. So in your code you can provide clean up methods to make sure that your objects are eligible for garbage collection once you are finished with those objects. This does not mean that your memory will be immediately released.


Your memory would not be released until the Garbage Collection starts to run to free up your memory.


java j2ee job interview questions with answers | Learn the core concepts and the key areas
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Memory
 
Similar Threads
Tag Library and Struts Framework
WA #1.....word association
char doubt
How to pass the values between MIDlets?
Jess in J2ME