PDA

View Full Version : سوال: مفهوم garbage collection در جاوا



ucnazard
جمعه 18 دی 1388, 18:27 عصر
میشه راجع به این موضوع کسی مقاله بذاره ممنون میشم:گریه:

mazdadoost
جمعه 18 دی 1388, 20:10 عصر
میشه راجع به این موضوع کسی مقاله بذاره ممنون میشم:گریه:
http://rapidshare.com/files/332271530/memorymanagement_whitepaper.pdf.html

gh-reza
جمعه 18 دی 1388, 20:34 عصر
http://www.javaworld.com/javaworld/jw-08-1996/jw-08-gc.html?page=2

و حتی جلوتر از اون

http://www.google.com/search?client=opera&rls=en&q=java+garbage+collection+article&sourceid=opera&ie=utf-8&oe=utf-8

مرتضی پیروزی
جمعه 18 دی 1388, 20:40 عصر
اتفاقا من هم داشتم واست تو گوگل میگشتم به لینک اول دوست عزیز gh-reza
رسیدم,خوبه بخونش

powerboy2988
جمعه 18 دی 1388, 21:52 عصر
گرفته شده از كتاب thinking in java :



Garbage collection is only about memory.
That is, the sole reason for the existence of the garbage collector is to recover memory that
your program is no longer using. So any activity that is associated with garbage collection,
most notably your finalize( ) method, must also be only about memory and its
deallocation.
Does this mean that if your object contains other objects finalize( ) should explicitly release
those objects? Well, no – the garbage collector takes care of the release of all object memory
regardless of how the object is created. It turns out that the need for finalize( ) is limited to
special cases, in which your object can allocate some storage in some way other than
creating an object. But, you might observe, everything in Java is an object so how can this
be?
It would seem that finalize( ) is in place because of the possibility that you’ll do something
C-like by allocating memory using a mechanism other than the normal one in Java. This
can happen primarily through native methods, which are a way to call non-Java code from
Java. (Native methods are discussed in Appendix A.) C and C++‎ are the only languages
currently supported by native methods, but since they can call subprograms in other
languages, you can effectively call anything. Inside the non-Java code, C’s malloc( ) family
of functions might be called to allocate storage, and unless you call free( ) that storage will
not be released, causing a memory leak. Of course, free( ) is a C and C++‎ function, so you’d
need call it in a native method inside your finalize( ).