LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 10-18-2007, 06:48 AM   #1
ycvlee
LQ Newbie
 
Registered: Oct 2007
Posts: 1

Rep: Reputation: 0
Where is the missing 4M memory in my 16M embedded linux system??


Dear all,

My embedded linux device has 16MB of RAM. I tried to allocate 8MB of memory by using a small program "malloc_test". After that, I computed how much free memory is left in my system. My calculation gives me 4140K but the /proc/meminfo shows only 256K free. Can someone please help me to figure out whether my calculation is wrong or the /proc/meminfo is wrong or the /proc/$PID/stat where "ps" gets its VmSize(VmRss) data is wrong ?
Thanks a lot...

Code:
$$$ =======================================================
$$$ Original memory information after booting up
$$$ =======================================================

wlan[0,0]-> cat /proc/iomem

00000000-00ffffff : System RAM
  00041000-001cbe97 : Kernel code
  001e4000-001fbfff : Kernel data

$$$ =======================================================
$$$ Kernel size: 1617559(1580K code) + 98303(96K data) = 1676K
$$$ =======================================================

wlan[0,0]-> lsmod

Module                  Size  Used by    Tainted: P
ath_ahb                67376  1
wlan_xauth               332  0 (unused)
wlan_wep                4092  0 (unused)
wlan_tkip              10492  0 (unused)
wlan_ccmp               5820  0 (unused)
wlan_acl                2572  1
ath_dfs                26880  0 [ath_ahb]
ath_rate_atheros       25976  0 [ath_ahb]
ath_hal               185520  1 [ath_ahb ath_rate_atheros]
wlan_scan_sta           8444  0 (unused)
wlan_scan_ap            2508  0 (unused)
wlan                  146448  1 [ath_ahb wlan_xauth wlan_wep wlan_tkip wlan_ccmp wlan_acl ath_rate_atheros wlan_scan_sta wlan_scan_ap]

$$$ =======================================================
$$$ Kernel modules size: 486460 = 475K
$$$ =======================================================

wlan[0,0]-> ps

  PID  Uid     VmSize Stat Command
    1 root        412 S   init
    2 root            SW  [keventd]
    3 root            RWN [ksoftirqd_CPU0]
    4 root            SW  [kswapd]
    5 root            SW  [bdflush]
    6 root            SW  [kupdated]
    8 root            SW  [mtdblockd]
   18 root        420 S   logger -s -p 6 -t
   20 root        600 S   /bin/ash --login
   22 root        372 S   klogd
   50 root            SWN [jffs2_gcd_mtd2]
   88 root        276 D   ifconfig eth0 up
  333 root        276 D   ifconfig eth0 up
 1984 root        468 S   udhcpc -t 0 -i eth0 -H AcctonAP -b -p /var/run/eth0.p
 2180 root        408 S   /sbin/syslogd -C16 -m 0
 2583 root        384 S   crond -c /etc/crontabs
 2641 root        420 S   httpd -p 80 -h /www -r AcctonAP
 2834 root        348 S   telnetd -l /bin/login
 2840 root        308 S   /sbin/watchdog /dev/misc/watchdog
 2841 root        300 D   /sbin/watchdog /dev/misc/watchdog
 3081 nobody      416 S   dnsmasq -F 192.168.1.100,192.168.1.149,255.255.255.0,
 3194 root        400 S   /usr/sbin/dropbear -p 22
 5188 root        388 R   ps

$$$ =======================================================
$$$ Process VmRSS memory usage: 5612K
$$$ only count 1 instance of: ifconfig and watchdog
$$$ =======================================================

wlan[0,0]-> cat /proc/meminfo

        total:    used:    free:  shared: buffers:  cached:
Mem:  14307328  9793536  4513792        0  1064960  3198976
Swap:        0        0        0
MemTotal:        13972 kB
MemFree:          4408 kB
MemShared:           0 kB
Buffers:          1040 kB
Cached:           3124 kB
SwapCached:          0 kB
Active:           2880 kB
Inactive:         1328 kB
HighTotal:           0 kB
HighFree:            0 kB
LowTotal:        13972 kB
LowFree:          4408 kB
SwapTotal:           0 kB
SwapFree:            0 kB

$$$ =======================================================
$$$ Total memory:           13972K
$$$ Total Process VmRSS:     5612K
$$$ Page Cache:              3124K
$$$ Buffer Cache:            1040K
$$$ ==============================
$$$ Free:                    4196K  seems correct...
$$$ =======================================================

wlan[0,0]-> free

              total         used         free       shared      buffers
  Mem:        13972         9472         4500            0         1040
 Swap:            0            0            0
Total:        13972         9472         4500

$$$ =======================================================
$$$ Now, try to malloc 8 mega bytes of memory
$$$ =======================================================

wlan[0,0]-> ./malloc_test 8 &
malloc success 0-th mega at 0x2ABE1008
malloc success 1-th mega at 0x2ACE2008
malloc success 2-th mega at 0x2ADE3008
malloc success 3-th mega at 0x2AEE4008
malloc success 4-th mega at 0x2AFE5008
malloc success 5-th mega at 0x2B0E6008
malloc success 6-th mega at 0x2B1E7008
malloc success 7-th mega at 0x2B2E8008

$$$ =======================================================
$$$ The system responses extremely slow now....
$$$ =======================================================

wlan[0,0]-> ps

  PID  Uid     VmSize Stat Command
    1 root         72 S   init
    2 root            SW  [keventd]
    3 root            SWN [ksoftirqd_CPU0]
    4 root            SW  [kswapd]
    5 root            SW  [bdflush]
    6 root            SW  [kupdated]
    8 root            SW  [mtdblockd]
   18 root         80 S   logger -s -p 6 -t
   20 root        152 S   /bin/ash --login
   22 root         60 S   klogd
   50 root            SWN [jffs2_gcd_mtd2]
   88 root         44 D   ifconfig eth0 up
  272 root         44 D   ifconfig eth0 up
 1638 root         96 S   udhcpc -t 0 -i eth0 -H AcctonAP -b -p /var/run/eth0.p
 2049 root         72 S   /sbin/syslogd -C16 -m 0
 2532 root         60 S   crond -c /etc/crontabs
 2541 root         60 S   /usr/sbin/dropbear -p 22
 2592 root         84 S   httpd -p 80 -h /www -r AcctonAP
 2785 root         64 S   telnetd -l /bin/login
 2791 root         56 S   /sbin/watchdog /dev/misc/watchdog
 2792 root         56 D   /sbin/watchdog /dev/misc/watchdog
 3027 nobody       64 S   dnsmasq -F 192.168.1.100,192.168.1.149,255.255.255.0,
 3824 root       8260 S   ./malloc_test 8
 3826 root        144 R   ps

$$$ =======================================================
$$$ Process VmRSS memory usage: 9368K
$$$ only count 1 instance of: ifconfig and watchdog
$$$ =======================================================

wlan[0,0]-> cat /proc/meminfo

        total:    used:    free:  shared: buffers:  cached:
Mem:  14307328 14045184   262144        0   143360   331776
Swap:        0        0        0
MemTotal:        13972 kB
MemFree:           256 kB
MemShared:           0 kB
Buffers:           140 kB
Cached:            324 kB
SwapCached:          0 kB
Active:            200 kB
Inactive:          312 kB
HighTotal:           0 kB
HighFree:            0 kB
LowTotal:        13972 kB
LowFree:           256 kB
SwapTotal:           0 kB
SwapFree:            0 kB

$$$ =======================================================
$$$ Free memory computation:
$$$ =======================================================
$$$ Total memory:           13972K
$$$ Total Process VmRSS:     9368K
$$$ Page Cache:               324K
$$$ Buffer Cache:             140K
$$$ ==============================
$$$ Free:                    4140K  differs by 3900K???
$$$ =======================================================

wlan[0,0]-> free

              total         used         free       shared      buffers
  Mem:        13972        13692          280            0          104
 Swap:            0            0            0
Total:        13972        13692          280
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Porting linux to embedded system. swapnilborg Linux - Software 0 12-21-2005 04:31 AM
Getting linux to boot on embedded system BleedingEdge Linux From Scratch 3 06-19-2005 06:36 AM
Writing to an read-only embedded linux system!! cheema Linux - General 1 01-26-2005 04:20 PM
Gpio Twiddling In Embedded Linux? or How to access PCI memory space regs? jds-linux Programming 1 07-11-2004 02:17 AM
Who Customize Linux for an Embedded System usage? Rajaee Linux - Software 0 08-18-2003 03:29 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 04:53 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration