* Memory Usage Growth in File access
@ 2005-05-02 6:52 s.deepak
2005-05-02 10:28 ` Wolfgang Denk
0 siblings, 1 reply; 2+ messages in thread
From: s.deepak @ 2005-05-02 6:52 UTC (permalink / raw)
To: linuxppc-embedded
[-- Attachment #1.1: Type: text/plain, Size: 1224 bytes --]
Hi All,
I am facing an issue in file operation, when we read/write continuously to a large file in our ppc 405 based device , memory usage shown in /proc/meminfo increases by the number of bytes accessed.And after closing the application also the memory used is not released and it goes to cached memory .
We are using 2.4.20 kernel in our device.We are not sure whether the /proc/meminfo shows the erroneous output or the file read/write routines got any problem.
Can anyone suggest me some idea how to trace out the problem.
I have given the sample code below.
The memory consumption grows and it takes about 10 MB memory space [10000 * 1024] when i run the below given code.
When i look into /proc/meminfo the free memory is reduced by 10 MB and Cache Memory & Used memory is increased by 10 mb after running this application.
When i run the below given code first time the memory grows,when i run succesively it doesn't grow again , may be using the already taken memory.
int main()
{
FILE *fp;
unsigned long int i;
unsigned char data[1024];
fp=fopen("test.txt","r");
for(i=0;i<10000;i++)
{
fread(data,1024,1,fp);
}
fclose(fp);
}
With Thanks & Regards,
Deepak S
[-- Attachment #1.2: Type: text/html, Size: 2246 bytes --]
[-- Attachment #2: BitDefender.txt --]
[-- Type: text/plain, Size: 824 bytes --]
--
This message contains information from GDA Technologies LTD and affiliates, and is intended for the sole use of the individual and entity to whom it is addressed. It may contain information, including any attachments, that is privileged, confidential and exempt from disclosure under applicable law. If you are not the intended addressee, nor authorized to receive for the intended addressee, you are hereby notified that you may not use, copy, disclose or distribute to anyone the message or any information contained in the message. If you have received this electronic transmission in error, please notify the sender immediately by a "reply to sender only" message and destroy all electronic and hard copies of the communication, including attachments.
This message was scanned for spam and viruses by BitDefender.
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Memory Usage Growth in File access
2005-05-02 6:52 Memory Usage Growth in File access s.deepak
@ 2005-05-02 10:28 ` Wolfgang Denk
0 siblings, 0 replies; 2+ messages in thread
From: Wolfgang Denk @ 2005-05-02 10:28 UTC (permalink / raw)
To: s.deepak; +Cc: linuxppc-embedded
In message <02cb01c54ee3$87e93ec0$4000a8c0@DeepakS> you wrote:
>
> I am facing an issue in file operation, when we read/write continuously
> to a large file in our ppc 405 based device , memory usage shown in
> /proc/meminfo increases by the number of bytes accessed.And after
> closing the application also the memory used is not released and it
> goes to cached memory .
Welcome to the world of efficient use of resources.
What you see is perfectly normal behaviour and one of the reasons
that LInux provides excellent performance.
> Can anyone suggest me some idea how to trace out the problem.
There is no problem. What you see is normal the way it was designed
to work.
> When i run the below given code first time the memory grows,when i run
> succesively it doesn't grow again , may be using the already taken
> memory.
Indeed. Also if you have a way to trace accesses to your storage
media you will see that the secondrun needs much less accesses, and
is faster, too.
Welcome to Unix.
Best regards,
Wolfgang Denk
--
Software Engineering: Embedded and Realtime Systems, Embedded Linux
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd@denx.de
Today is the yesterday you worried about tomorrow.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2005-05-02 10:28 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-05-02 6:52 Memory Usage Growth in File access s.deepak
2005-05-02 10:28 ` Wolfgang Denk
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).