2009-03-01 22:52:12     Runing out of memory and app which write data to sd car is kill by oom-killer in svn+527

Document created by Aaronwu Employee on Aug 14, 2013
Version 1Show Document
  • View in full screen mode

2009-03-01 22:52:12     Runing out of memory and app which write data to sd car is kill by oom-killer in svn+527

Bill Xie (CHINA)

Message: 70189   

 

Hi,

 

     Last time I ask about this question in forum and I spent some days to rearch this question.but I cannot find out way to solve this problems.

 

My test appliction:

 

 

 

#include <stdio.h>

#include <sys/time.h>

#include <unistd.h>

#include <sys/types.h>

#include <sys/stat.h>

#include <fcntl.h>

#include <sys/ioctl.h>

#include <sys/vfs.h>

int main()

{

    struct timeval tv,tv1;

   struct timezone tz,tz1;

   FILE * fp;

   short buf[160] = {0};

   int num = 0;

   int i = 0;

   float time;

   char filebuf[100];

   system("echo 3 > /proc/sys/vm/drop_caches");

   system("echo 300 > /proc/sys/vm/vfs_cache_pressure");

   system("echo 50 > /proc/sys/vm/pagecache_ratio");

 

  // system("mount -t vfat /dev/mmcblk0 /mnt");

    i=0;

   gettimeofday(&tv,&tz);

    sprintf(filebuf,"/mnt/%d.bin",tv.tv_sec);

    printf("filename=%s\n",filebuf);

   fp=fopen(filebuf,"w+");

   if(fp == NULL)

   {

      printf("open file faild\n");

    return -1;

   }

 

  // gettimeofday(&tv,&tz);

   printf("fwrite before tv_sev: %d\n",tv.tv_sec);

   printf("fwrite before tv_usec:%d\n",tv.tv_usec);

   while(1)

   {

        num = fwrite(buf,sizeof(short),160,fp);

       if( num!= 160)

           {

               printf("write data %d is not equal to 160 \n",num);

               break;

           }

//         fflush(fp);

        if(i>199999)

            {

               printf("write data ok %d\n",i);

                break;

            }

         i++;

          if(i%100==0)

            system("cat /proc/meminfo >>/mnt/2.txt");

   }

    gettimeofday(&tv1,&tz1);

   printf("fwite after tv_sev: %d\n",tv1.tv_sec);

   printf("fwite after tv_usec:%d\n",tv1.tv_usec);

  time= (tv1.tv_sec-tv.tv_sec-1)*1000+(1000000+tv1.tv_usec-tv.tv_usec)/1000;

   printf("320 bytes take time is %f ms\n",time/i);

   fclose(fp);

 

   return 0;

}

 

 

When the  app is running, it is killed by oom-killer.

 

syslogd invoked oom-killer: gfp_mask=0x200d2, order=0, oomkilladj=0

Hardware Trace:

   0 Target : <0x00004b14> { _dump_stack + 0x0 }

     Source : <0x0003234e> { _oom_kill_process + 0xd6 } CALL pcrel

   1 Target : <0x0003234e> { _oom_kill_process + 0xd6 }

     Source : <0x0001014a> { _printk + 0x16 } RTS

 

File 2.txt is about  /proc/meminfo message. The memory can be reclaimed by system in 2.txt file. How to reclaim memory in time?

 

2.txt

QuoteReplyEditDelete

 

 

2009-03-02 06:52:47     Re: Runing out of memory and app which write data to sd car is kill by oom-killer in svn+5

Robin Getz (UNITED STATES)

Message: 70213   

 

Bill:

 

On what sort of file system are you running? if it is the default - you are just filling it up with your files.

 

-Robin

QuoteReplyEditDelete

 

 

2009-03-05 02:14:02     Re: Runing out of memory and app which write data to sd car is kill by oom-killer in svn+5

Bill Xie (CHINA)

Message: 70404   

 

Hi Robin,

 

    Thank you for your reply. I am sorry for not responses in time due to I am busy for other thing.In my system,

 

 

 

root:/proc> cat filesystems

nodev   sysfs

nodev   rootfs

nodev   bdev

nodev   proc

nodev   debugfs

nodev   sockfs

nodev   usbfs

nodev   pipefs

nodev   anon_inodefs

nodev   tmpfs

nodev   inotifyfs

nodev   configfs

nodev   devpts

        ext2

nodev   ramfs

        vfat

        msdos

nodev   jffs2

root:/proc>

 

>>>>>>>>>>>>>>

 

>>>>>>> if it is the default - you are just filling it up with your files.

 

     I cann't understand  this word.

 

 

 

 

 

--Bill

Attachments

Outcomes