Re: Re: Memory leak (Jim Rudnicki)

Shawn Silverman <[email protected]> Thu, 27 May 2004 09:58:08 -0500 (CDT)
Newsgroups gmane.comp.hardware.microcontrollers.tini
Message-ID <[email protected]>
> The typical Java performs automatic garbage collection. By nulling
> objects, you allow Java to recycle the memory for other purposes,
> however, this is not the case with the TINI, at least not when I have
> tried this.  I null almost all variables, yet I still have memory leaks
> in my program, which causes my TINI to eventually reset itself and

Then you are allocating resources somewhere that are still being
referenced.  One example is not closing socket objects on the TINI, and
another is an object that is inside, say, a Vector or Hashtable.

> sometimes makes it lose all its RAM data. Hence, a System.gc command was
> my solution for my memory leak.
>
> Also Chris, if you read the java docs for System.gc, you will find out
> that it is a function that is dangerous to use in typical applications
> because the programmer has no control over what Java  erases. This is

This is simply not true.  Java garbage collection does *not* erase
referenced memory *unless* it is some type of "soft" or "weak" reference
(java.lang.ref), but TINI does not have these.  The Java spec does not
imply that the GC erases needed objects.

	-Shawn

> why I made sure all objects/variables has been nulled and any important
> information was saved elsewhere before executing this piece of code.
>
> Hong
>
> Chris Fox wrote:
>
> >Hong -
> >
> >I am not that  much of a Java guy, so correct me if I am wrong, but running
> >the garbage collector should never "wipe out variables/objects you don't want
> >to erase". That's not garbage! You should be able to run the gc any time you
> >want to, and it should NEVER do anything but free memory and take some CPU
> >time!
> >
> >Chris
_______________________________________________
TINI mailing list
TINI-6tN4nzCoH/[email protected]
To UNSUBSCRIBE, edit your profile, or see list archives:
http://lists.dalsemi.com/mailman/listinfo/tini