I got a doubt with memory allocation in Linux I am having 256 MB of RAM in my portable player and the linux kernel is given with parameter "MEM=110M" while booting, Can any one explain what does that mean Is it a ... 1) 110 M is given for Kernel memory and remaining 146 is for user-space memory or 2) 110M is given for kernel & user-space and remaining can be configured as per requirement (may be... say, driver memory) Also, when i start a application that has many malloc in it., at some point the malloc() function returns null., whereas i parallely checking through Telnet for the "free memory space" through "free" cmd, it returns 39 MB as unused (ie., free) I am little confused now (may be i am not knowing the memory partitions), can any one explain on this Thanks in advanceThanks Jlliagre, My free observation is here
" Jlliagre --- Malloc is allocating virtual memory while free is displaying RAM and SWAP usage " fine, then does it mean that virtual memory for a process is fixed amount so that other processes will also get memory, instead of putting other processes running out of memory. my concern is even-though free shows 39868 KB, it fails on malloc() of 2.5 MB asked 02 May '10, 11:14 thinku |
My understanding of this option is that 110M are given for kernel & user-space and the remaining 146 are wasted as far a Linux is concerned. The BIOS might use it but it's unlikely to be useful in your case. Normally, that's the other way around. This option was created to allow Linux to use all of your memory if for some reason it wasn't able to detect the whole of it at boot time. As of malloc and free discrepancies. Malloc is allocating virtual memory while free is displaying RAM and SWAP usage. These are not strictly related, especially when overcommitting is enabled. Add "free" output to you question to clarify. answered 03 May '10, 10:07 jlliagre Thansk Jlliagre, My free observation is here free
Mem: 106428 66560 39868 0 5240 " Jlliagre --- Malloc is allocating virtual memory while free is displaying RAM and SWAP usage " fine, then does it mean that virtual memory for a process is fixed amount so that other processes will also get memory, instead of putting other processes running out of memory. my concern is eventhough free shows 39868 KB, it fails on malloc() of 2.5 MB
(04 May '10, 05:15)
thinku
|
mem=0 option enables kernel to boot and use all the available memory. In you case all 256 MB. Now 110 M means,remaining 146 M is wasted. answered 03 May '10, 12:09 Pradeep Specifying "mem=0" is pointless as the kernel will use all available memory by default.
(03 May '10, 13:30)
jlliagre
|
Do you use onboard video? Most onboard GPUs like to take system RAM and convert it to VRAM so they can function properly. That could be what's happening there. Might be good to upgrade to an actual video card. Then again, most integrated GPUs don't take over 25% of system RAM. I personally am not suffering this problem as I have a PCI-E video card and I don't see my kernel allocating anything less than what my system actually has. answered 03 May '10, 16:32 Yaro Kasear |
Yes; now i got some more information, i could allocate memory without any issues by setting
Further on googling and on some discussion Since Kernel version 2.5.30 the values for
Here /proc/sys/vm/overcommit_ratio (by default 50) is another user-settable parameter. so out of my 110 MB 50 % is allocatable and remaining are for left "free" for other operations..(i guess for other processes too .. need to experiment on this) ence by changing this to 80 %; now i am getting successive malloc() operation (See also Documentation/vm/overcommit-accounting) answered 05 May '10, 08:48 thinku You got it wrong. Out of your 110 MB, "180%" is allocatable. Your successful mallocs are therefore quite unreliable.
(05 May '10, 11:49)
jlliagre
jlliagre. i missed to update the one more change that i did. I changed the overcommit_memory to 2; and set the ratio as 80 %;
(06 May '10, 10:27)
thinku
|
Here is my Observation
Further from Generated by /proc/meminfo.
answered 06 May '10, 10:34 thinku |
Please format free output for readability. Is it missing a Swap line ? What is that portable player in the first place ? malloc shouldn't fail if there is really 39MB available. Try adding system("free"); just before the malloc to make sure.
Please accept an answer so the question/answer can be finished. Or provide more details so we can help.