× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Christen, Duane J. wrote:
You are the best, and at times, the worst garbage collector known, a
programmer. Even the best garbage collection algorithm(s) can not
beat a well informed programmer.

Duane:

I think you're misunderstanding what a garbage collectors job is ... at
least as *I* know GC.

Generally speaking GC is used to free up memory occupied by data that
is no longer used. This is not a function a programmer can or should
be doing. In fact, I think it's generally a function outside of what an
application programmer can really do.

In Java, any objects that are actively in use will *NOT* be GC'ed. An
object has a reference when some other object still refers to it (or
contains it). You can remove that reference by setting all variables
that refer to the object to null or replacing the value of the variable
with another value.

For example ...

String s1 = new String("1"); // object "1" has a reference
String s2 = s1; // object "1" has two references
s1 = null; // object "1" now has one reference
s2 = null; // object "1" still exists, but no longer has
// any references to it and can can be GC'ed.

Also, in Java, even an explicit call to the garbage collector is just a
request to do garbage collection. Not a command to do so. Other languages work differently of course.

If, however, you're taking about deallocating memory that was programactially allocated by the application, then no GC routine in existence can clean that up ... as only the application knows what is still in use. The only time the system can know that the memory is no longer in use is when the memory truly goes out of scope (in RPG terms, I think that would be the activation group level). In this case it is truly the programmers job to deallocate memory the application has allocated when appropriate.

'course, I could be wrong. :)

david


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.