Out of memory: system();

Ed K. ed at hp.uab.edu
Sat Jun 12 04:37:02 UTC 2004


On Fri, 11 Jun 2004, fredex wrote:
> On Fri, Jun 11, 2004 at 07:11:25PM -0400, Ed K. wrote:
>> On Fri, 11 Jun 2004, fredex wrote:
>>> On Fri, Jun 11, 2004 at 01:45:00PM -0400, Ed K. wrote:
>>>> I have fedora core2 installed with kernel: kernel-2.6.5-1.358
>>>>
>>>> I must call system(....) about 300,000 times from a process that has 175MB
>>>> allocated on a computer with only 256MB of RAM. But after about the
>>>> 5,000th
>>>> call, i get an out of memory error (errno: 12 Cannot allocate memory) when
>>>> I call the system function.
>>>
>>> Sounds like a pretty dangerous thing to be doing. You're sure there's
>>> no better way to design this program?
>>>
>>> If you give some more details on what you're doing and why it
>>> has to be done this way, perhaps someone can ofer some helpful
>>> suggestions.
>>>
>>
>> I don't know how much I can tell about the project, doesn't that suck?
>> But you can read some of the publicity at:
>> http://www.phppo.cdc.gov/cyto/CytoView_Demo.asp
>>
>> Sorry, but you need a windows client to view the demos.
>>
>> I do have a working test:
>>
>> #include <stdio.h>
>> #include <unistd.h>
>> #include <stdlib.h>
>> #include <errno.h>
>>
>> int main(int argc, char *argv[])
>> {
>>   unsigned char *data;
>>   int i;
>>
>>   data=malloc(500*1024*1024);
>>   memset(data,0,500*1024*1024);
>>
>>   for (i=0; i<100000; i++)
>>     system("cat /proc/meminfo");
>> }
>>
>> This does not cause problems on FC1 (kernel 2.4.22-1.2188) But does on FC2
>> (kernel 2.6.5-1.358)
>>
>> Is this a glibc bug or a kernel bug?
>
> Good question!
>
> it's running (apparetly) fine on my TAO linux box, but it's kernel 2.4.x
> and has a gig of RAM.
>

That is my experience too. Works great on all my 2.4 kernels and causes a 
memory leak on the 2.6 kernels. Wonder if anyone else notices a memory 
leak on their 2.6 kernels.

ed

Security on the internet is impossible without strong, open, 
and unhindered encryption.





More information about the fedora-list mailing list