From: Haiyang C. <hai...@ag...> - 2008-11-04 19:15:16
|
Dave: Thanks for your suggestion. I checked my "top" out put , there are some parts called buffer and cached. My program does cause the increasing of cached memory, but it does not count for all the used memory increasing from my observation. I also checked /proc/meminfo, but I haven't find out how often /proc/meminfo is updated yet. I guess I need to try more ways of checking the memory usages on gumstix. Regards Haiyang On Mon, Nov 3, 2008 at 10:06 PM, < gum...@li...> wrote: > > Message: 1 > Date: Mon, 3 Nov 2008 15:47:42 -0800 > From: "Dave Hylands" <dhy...@gm...> > Subject: Re: [Gumstix-users] Memory Leak Problem on high-speed file > logging > To: "General mailing list for gumstix users." > <gum...@li...> > Message-ID: > <c32...@ma...> > Content-Type: text/plain; charset=ISO-8859-1 > > Hi Haiyang, > > > I got a memory leak problem while trying to write to my log file. The > used > > memory just kept increasing about 12k every 5 seconds when I used "top" > to > > monitor the system resources. > > > > I am using verdex Pro XM4 for serial data acquisition and real-time data > > logging. My code just keeps reading from the serial port and save the > data > > to the SD card of gumstix. The data coming in is 50Hz. I have 62 bytes > data > > every time so it is 62*50=3100 bytes/second. > > > > I am using fwrite to write a structure every 0.02s and fflush, fsync > every > > 1s. Due to my embedded requirements, I can't stop the logging once the > power > > is on. So I did not close the file in my program. It is just a while loop > > that never stops. > > > > I checked the BUFSIZ, which is 8192 for my gumstix. So I don't think it > is a > > buffer overflow problem. I guess the memory increasing is caused by > system > > kernel level because the sytem may not flush the kernel buffer although I > > flushed my program buffer. Due to some reason the system just won't write > to > > disk this often. So the data just waits in the memory for writing to > disk. > > But the memory is leaking anyway. I really want to get rid of this > through > > some way. > > Linux will cache your writes in free memory just in case you decide to > go back and read it. I'm not quite sure how this gets accounted for > from the "top" perspective. > > Check /proc/meminfo > > If Buffers or Cached is what increases, then this is fine. Those pages > will be "kicked out" when the OS needs the memory for something else. > > -- > Dave Hylands > Shuswap, BC, Canada > http://www.DaveHylands.com/ > > > > |