2011-02-22 04:44:57     Delete shared memory.

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

2011-02-22 04:44:57     Delete shared memory.

Alf Nilsson (SWEDEN)

Message: 98331   

 

Hi all,

 

I'm having a bit of odditioes with shared memory.

 

I am using 2010R1-RC5.

 

Now what I am trying to do.

 

I allocate quite a lot of shared memory using shmat.

 

I detach the same memory with shmdt.

 

I deallocate with shmctl(shmID, IPC_RMID, NULL ).

 

ipcs -m show no shared memory segments after the application has teminated.

 

But...

 

Before running : 50 MB free

 

During running : 40 MB free.

 

After running : 42 MB free.

 

Each time I run the test I lose 8 MB per run.

 

And all the test does is allocate and free shared memory.

 

Has anyone else seen something like this?

 

Cheers,

 

//Alf

QuoteReplyEditDelete

 

 

2011-02-22 12:37:08     Re: Delete shared memory.

Mike Frysinger (UNITED STATES)

Message: 98341   

 

post a simple test case that shows the problem, and verify that your memory calculation isnt ignoring caches.

QuoteReplyEditDelete

 

 

2011-02-23 04:32:16     Re: Delete shared memory.

Alf Nilsson (SWEDEN)

Message: 98370   

 

I've created a simple test program in eclipse for BF561-0.5.

 

The test has been run on a custom board which is very similar to the BF-561-EZ-Kit.

 

Tests that have been run....

 

top - Note the available ram and amount of cache.

 

ipcs - View the number of shared memory segments and sizes.

 

shared_test - Do NOT press enter.

 

top - Note the available ram and amount of cache.

 

ipcs - View the number of shared memory segments and sizes.

 

shared_test - Now press enter.

 

top - Note the available ram and amount of cache.

 

ipcs - View the number of shared memory segments and sizes.

 

Output from test run:

 

Before:

 

Mem: 13120K used, 49336K free, 0K shrd, 0K buff, 6196K cached

 

During:

 

Mem: 21524K used, 40932K free, 0K shrd, 0K buff, 14004K cached

 

After:

 

Mem: 20956K used, 41500K free, 0K shrd, 0K buff, 6212K cached

 

sync; echo 3 > /proc/sys/vm/drop_caches

 

Mem: 20820K used, 41636K free, 0K shrd, 0K buff, 6196K cached

 

I also compiled the same project for linux and tested.

 

I do not at all see the same behavior in linux.

 

Any further suggestions?

 

Cheers,

 

//Alf

 

shared_test.tar.gz

QuoteReplyEditDelete

 

 

2011-03-03 01:58:51     Re: Delete shared memory.

Mike Frysinger (UNITED STATES)

Message: 98619   

 

there does seem to be a small memory leak, but i dont think it's a matter of the shared mem not being deleted.  looks more like some internal structures are not being released when the shared memory segments are freed.

 

your test can be further reduced down.  simply call shmget() followed by shmctl(IPC_RMID).

 

ive opened a tracker item for this issue:

    blackfin.uclinux.org/gf/tracker/6502

Attachments

Outcomes