Running out of memory

Go To Last Post
9 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm running out of memory (SRAM) on an STK1002 based system I'm developing. It has 8M SRAM, About 2M us kernel, etc., so I have about 6M application space. I thought that would be enough as I'm only running shell scripts and one or two custom applications.

However, I'm finding every applications seems to want 1M of VSZ. See top output below. At this point it is okay, but I get out of memory erros when I plug in a sd-card, and applications get randomly killed.

I have managed to capture the point just before the out of memory, and I see a shell running mdev, the mdedev app, and finally my automount script called out of mdev.conf. each take 1M plus a bit.

So, I have quite a few questions...

1. why do all apps take 1M plus a bit?
2. Is there a way to reduce the 1M?
3. would that actually help?

Sample top output...
(note 'myapp' is my main background application)

  0% usr   0% sys   0% nice  99% idle   0% io   0% irq   0% softirq
Mem: 4264K used, 1740K free, 0K shrd, 44K buff, 1536K cached
CPU:  73% usr  10% sys   0% nice  15% idle   0% io   0% irq   0% softirq
Load average: 0.53 0.21 0.14
  PID  PPID USER     STAT   VSZ %MEM %CPU COMMAND
  498   324 root     R     1588  26%  83% myapp 
  324     1 root     R     1008  17%   0% top 
    1     0 root     S     1008  17%   0% init       
  225     1 root     S     1004  17%   0% /sbin/klogd 
    6     2 root     SW<      0   0%   0% [khelper]
   70     2 root     SW<      0   0%   0% [kmmcd]
    3     2 root     SW<      0   0%   0% [ksoftirqd/0]
   60     2 root     SW<      0   0%   0% [kblockd/0]
    4     2 root     SW<      0   0%   0% [watchdog/0]
   94     2 root     SW       0   0%   0% [pdflush]
   96     2 root     SW<      0   0%   0% [kswapd0]
   97     2 root     SW<      0   0%   0% [aio/0]
  140     2 root     SW<      0   0%   0% [mtdblockd]
   95     2 root     SW       0   0%   0% [pdflush]
    2     0 root     SW<      0   0%   0% [kthreadd]
  439     2 root     SW<      0   0%   0% [mmcqd]
  465     2 root     SW<      0   0%   0% [file-storage-ga]
    5     2 root     SW<      0   0%   0% [events/0]
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I've run into the same issue and was planning on upgrading the memory chip, unfortunately the SDRAM on the STK1000 is using the x32 bus so it's not a straight swap if you want to go over 16MB.. Unless other manufacturers have higher density x32 devices, Micron seems limited.

Would creating a swap file on the SD-card help? I'm going to try that myself for my issues, and I'll post a guide once I figure out the correct procedure..

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I've run into the same issue and was planning on upgrading the memory chip, unfortunately the SDRAM on the STK1000 is using the x32 bus so it's not a straight swap if you want to go over 16MB.. Unless other manufacturers have higher density x32 devices, Micron seems limited.

Would creating a swap file on the SD-card help? I'm going to try that myself for my issues, and I'll post a guide once I figure out the correct procedure..

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The SD card 'fix' is a good idea, but can't help me as I'm in flash, and have a removable SD card.

I'm looking at the possibility more RAM, but the H/W design is already committed and I don't think I have the choice at this stage.

I am beginning to think I have to make one big monolithic application, rather than several smaller ones. However, this still leaves the problem of how to run scripts, etc., and all this greatly diminishes the whole reason for running a Linux kernel.

Feels there ought to be a better way.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I agree, it does seem like there is a lot of memory being used up there. I hope someone can give a good response as to why the processes take up so much mem and if there is a way to reduce that because it will apply to my project as well.. On my board design there is a 32MB sdram though so it won't be quite as pressing.

Still, should be more efficient than that..

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Maybe I should just rephrase this question: is 8M too little RAM to run AVR32 linux?

Is anyone successfully running applications (not just a shell) in 8Mbytes or RAM?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

No problems running applications and linux on my stk1002/stk1000... Also been able to do it on stk1004/stk1000 and that one has only 4MB ram.

Life's to short for waiting on slow CPU's

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Okay, so it's not the amount of RAM being too little, per se, that's the root cause of my problems. My main application also runs okay, when it's the only application running.

The problem comes when I insert an sd card. What seems to happen is I get a mini fork bomb - several scripts and helper applications fire to do the hotplugging. This can bring down the system with messages like..

Out of memory: kill process 503 (automount.sh) score 49 or a child     
Killed process 504 (mount)

It seems that one or two applications good, four or more applications bad. I don't have the option to increase memory, so how do I reduce the memory demands of the applications? Why do they all try to grab over 1M of memory?