Re: Re: Memory leak (Jim Rudnicki)

Hong Wong <[email protected]> Thu, 27 May 2004 09:49:56 -0400
Newsgroups gmane.comp.hardware.microcontrollers.tini
Message-ID <[email protected]>
Hi Chris,

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 
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 
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
>
>-----Original Message-----
>From: tini-admin-6tN4nzCoH/[email protected] [mailto:tini-admin-6tN4nzCoH/[email protected]] On Behalf Of Hong
>Wong
>Sent: Wednesday, May 26, 2004 1:14 PM
>To: tini-6tN4nzCoH/[email protected]
>Subject: [TINI]Re: Memory leak (Jim Rudnicki)
>
>
>Hello Tom and Jim,
>
>I also have had problems with the memory leaks, mainly because I am performing
>socket communications (which are known to have memory leaks when leaving
>socket communication open).  My application was to monitor and control a DC
>motor via the internet.  You guys can try the experiment at:
>http://mechatronics.poly.edu/TINIPaper/
>
>Now for my solution for memory leaks.  I perform a system garbage collect at
>subsequent iterations of my main program (i.e., System.gc() command is used).
>It does solve my problem with memory leaks however, this manual garbage
>collection scheme is quite dangerous since it wipes out large amounts of
>memory used by the program (even the variables/objects you don't want to
>erase).  Prior to using System.gc, I have tried to null all unused objects
>from my program.  However, this did not plug the leak (so to speak). Hopefully
>this technique may help solve your problem, Tom (or may make you more
>frustrated, depending of the results).  
>
>Thanks for listening
>
>Hong
>
>
>---------------- Previous Message --------------------
>Tom,
>
>I can only offer hope.  This is from my TINI that monitors temperature sensors
>on the 1-Wire about every 15 seconds and updates my database:
>
>TINI OS 1.02c
>
>System up time:
>      Days: 23
>     Hours: 21
>   Minutes: 5
>   Seconds: 9
>
>Free RAM: 145344
>
>The memory bounces up to a few hundred k and down to under 100 every few
>minutes, but it has never crashed.
>
>Jim
>
>----- Original Message -----
>From: "Tom Watson" <[email protected]>
>To: "tinilist" <tini-6tN4nzCoH/[email protected]>
>Sent: Monday, May 24, 2004 3:36 PM
>Subject: [TINI]Memory leak
>
>
>  
>
>>We just deployed a new version of our application into the pilot sites 
>>and it has developed a new problem. The application uses 1-Wire 
>>extensively
>>    
>>
>and
>  
>
>>starts with about 300K of free RAM. After about two days, the average 
>>free memory has declined to <64K and one of the threads quits, forcing 
>>the watchdog to restart the system. On the good side, it comes back up 
>>and operates normally. On the bad side, this cycle repeats every two 
>>days.
>>    
>>
>
>
>
>_______________________________________________
>TINI mailing list
>TINI-6tN4nzCoH/[email protected]
>To UNSUBSCRIBE, edit your profile, or see list archives:
>http://lists.dalsemi.com/mailman/listinfo/tini
>
>
>  
>


_______________________________________________
TINI mailing list
TINI-6tN4nzCoH/[email protected]
To UNSUBSCRIBE, edit your profile, or see list archives:
http://lists.dalsemi.com/mailman/listinfo/tini