How to free ramdisk memory

I ask for your help in solving a puzzle regarding how to minimize RAM in a set top box.

After boot the set top box has about 32 MB of RAM left. After boot we download a media player from a server. Our media player is 15 MB so we create a 15 MB RAM disk and download to it. We run the media player and immediately run out of RAM since the media player wants to allocate an additional 15 MB of buffers. If only we could load the program into memory, free the RAM disk, and then allocate the buffers from the freed RAM. We have all source code.

THE QUESTIONS:

- Do you know of a way to load a program into memory so that the open file to the executable can be closed allowing the unmounting of the file system?

- The video codec only has drivers for the 2.2 kernel. Do you know if CRAMFS and execute-in-place will work with a 2.2 kernel?

Thanks in advance Bob Smith

Reply to
Bob Smith
Loading thread data ...

Here is some simple code to illustrate the question.

# Make and mount a small RAM disk dd if=/dev/zero of=/dev/ram1 bs=1k count=100 mke2fs /dev/ram1 mkdir /mnt/test mount /dev/ram1 /mnt/test

# Build a trivial app and put it in /mnt/test cat >/mnt/test/hello.c

Reply to
Bob Smith

Not that I know of.

The route to solving your problem is to use a filesystem which supports "execute in place". I believe a short time ago Montavista open-sourced a file system they had developed which permits this.

With execute-in-place the memory required for the application is mapped onto the device directly, so the code is basically run directly out of the device instead of being copied into memory. If you create a ramdisk using Montavista's filesystem you should be able to achieve this. The only trick is, I think, that it needs to be allocated a region of memory outside of the kernel's domain.

Reply to
Geronimo W. Christ Esq

Since you use a ram file system with a fixed size you loose all the memory that it takes. "ramfs" however just takes the memory that is used. If you delete a file, the memory returns to the heap. So there no need to unmount the file system for releasing the memory(if you delete the unused files) To use ramfs:

- check that it is included in your kernel (very likely)

- mount is by: > mkdir /mnt/test > mount -t ramfs none /mnt/test

Reply to
Paul Geerinckx

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.