How to find virtual memory size and cache size of a linux system?

Is there any command to get virtual memory size, cache size and front side bus speed of a linux system? Is swap in linux same as virtual memory?

4

9 Answers

This question is completely contained in your previous question How to find virtual memory size and cache size of a linux system?. As pointed out in my answer to that question, the sudo dmidecode --type processor command gives you the "External Clock" speed, and FSB speed is a multiple (typically 2 or 4 times) of this speed.

If this did not work for you, you should edit your original question and tell us what output you got or what the error was. The more specific you are, the better others can help you.

As pointed out by The Journeyman geek, you can typically get the same "External Clock" measure from lshw, in the value reported for "clock" in the cpu related ouput.

 *-cpu description: CPU product: Genuine Intel(R) CPU T2300 @ 1.66GHz vendor: Intel Corp. physical id: 400 bus info: cpu@0 version: 6.14.8 serial: 0000-06E8-0000-0000-0000-0000 slot: Microprocessor size: 1GHz capacity: 1800MHz width: 32 bits clock: 133MHz capabilities: fpu fpu_exception wp vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe nx constant_tsc arch_perfmon bts pni monitor est tm2 xtpr pdcm cpufreq configuration: id=0 

Finally, you may find the external clock speed in the output of dmesg, though this is by no means a standard way of accessing this information. You may find the FSB speed via your BIOS settings, or by looking up your CPU spec, though these are not linux specific.

3

Yes, swap is virtual memory.

Virtual memory size Use swapon -s or free

$ swapon -s Filename Type Size Used Priority /dev/sda6 partition 1004020 39620 -1 $ free total used free shared buffers cached Mem: 3087892 2879036 208856 0 394288 835052 -/+ buffers/cache: 1649696 1438196 Swap: 1004020 39620 964400 

Cache size Get this from /proc/cpuinfo. The "cache size" field gives you the cache on the CPU. On multi-core machines, you'll see one entry per processor, with its own cache value.

$ cat /proc/cpuinfo processor : 0 vendor_id : GenuineIntel cpu family : 6 model : 14 model name : Genuine Intel(R) CPU T2300 @ 1.66GHz stepping : 8 cpu MHz : 1000.000 cache size : 2048 KB physical id : 0 siblings : 2 core id : 0 cpu cores : 2 apicid : 0 initial apicid : 0 fdiv_bug : no hlt_bug : no f00f_bug : no coma_bug : no fpu : yes fpu_exception : yes cpuid level : 10 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe nx constant_tsc arch_perfmon bts pni monitor est tm2 xtpr pdcm bogomips : 3324.64 clflush size : 64 power management: 

Front side bus (FSB) speed You can get this from the dmidecode utility, with the --type processor argument. You need sudo permission to run this command. The FSB is indicated by the speed reported for "External Clock". The actual speed is typically 4 times the reported speed, as those many instructions are executed per clock cycle.

$ sudo dmidecode --type processor # dmidecode 2.9 SMBIOS 2.4 present. Handle 0x0400, DMI type 4, 32 bytes Processor Information Socket Designation: Microprocessor Type: Central Processor Family: Pentium M Manufacturer: Intel ID: E8 06 00 00 FF FB E9 BF Signature: Type 0, Family 6, Model 14, Stepping 8 Flags: FPU (Floating-point unit on-chip) VME (Virtual mode extension) DE (Debugging extension) PSE (Page size extension) TSC (Time stamp counter) MSR (Model specific registers) PAE (Physical address extension) MCE (Machine check exception) CX8 (CMPXCHG8 instruction supported) APIC (On-chip APIC hardware supported) SEP (Fast system call) MTRR (Memory type range registers) PGE (Page global enable) MCA (Machine check architecture) CMOV (Conditional move instruction supported) PAT (Page attribute table) CLFSH (CLFLUSH instruction supported) DS (Debug store) ACPI (ACPI supported) MMX (MMX technology supported) FXSR (Fast floating-point save and restore) SSE (Streaming SIMD extensions) SSE2 (Streaming SIMD extensions 2) SS (Self-snoop) HTT (Hyper-threading technology) TM (Thermal monitor supported) PBE (Pending break enabled) Version: Not Specified Voltage: 3.3 V External Clock: 133 MHz Max Speed: 1800 MHz Current Speed: 1000 MHz Status: Populated, Enabled Upgrade: None L1 Cache Handle: 0x0700 L2 Cache Handle: 0x0701 L3 Cache Handle: Not Provided 
4

I do believe lshw has that info. However not all distros have it (hint- next time PLEASE mention what distro and version you use. It helps a lot. Also helps to be specific about what you did so far. 'some command like' is not good enough)

Try this on the Linux machine: cat /proc/pal/cpu0/cache_info

This will show something like:

Cache levels : 3 Unique caches : 5 Data Cache level 1: Size : 16384 bytes Attributes : WriteThrough Associativity : 4 Line size : 64 bytes Stride : 128 bytes Store latency : 0 cycle(s) Load latency : 1 cycle(s) Store hints : Load hints : [Temporal, level 1] Alias boundary : 4096 byte(s) Tag LSB : 12 Tag MSB : 49 Instruction Cache level 1: Size : 16384 bytes Attributes : Associativity : 4 Line size : 64 bytes Stride : 128 bytes Store latency : N/A Load latency : 1 cycle(s) Store hints : Load hints : [Temporal, level 1] Alias boundary : 4096 byte(s) Tag LSB : 12 Tag MSB : 49 Data Cache level 2: Size : 262144 bytes Attributes : WriteBack Associativity : 8 Line size : 128 bytes Stride : 128 bytes Store latency : 7 cycle(s) Load latency : 5 cycle(s) Store hints : [Temporal, level 1][Non-temporal, all levels] Load hints : [Temporal, level 1][Non-temporal, level 1][Non-temporal, all levels] Alias boundary : 4096 byte(s) Tag LSB : 15 Tag MSB : 49 Instruction Cache level 2: Size : 524288 bytes Attributes : Associativity : 8 Line size : 128 bytes Stride : 128 bytes Store latency : N/A Load latency : 7 cycle(s) Store hints : Load hints : [Temporal, level 1][Non-temporal, level 1][Non-temporal, all levels] Alias boundary : 4096 byte(s) Tag LSB : 16 Tag MSB : 49 Data/Instruction Cache level 3: Size : 4194304 bytes Attributes : Unified WriteBack Associativity : 8 Line size : 128 bytes Stride : 128 bytes Store latency : 7 cycle(s) Load latency : 14 cycle(s) Store hints : [Temporal, level 1] Load hints : [Temporal, level 1][Non-temporal, level 1] Alias boundary : 4096 byte(s) Tag LSB : 19 Tag MSB : 49 

Try ulimit -a, on my machine it will show something like:

core file size (blocks, -c) 0 data seg size (kbytes, -d) unlimited scheduling priority (-e) 0 file size (blocks, -f) unlimited pending signals (-i) 31321 max locked memory (kbytes, -l) 64 max memory size (kbytes, -m) unlimited open files (-n) 1024 pipe size (512 bytes, -p) 8 POSIX message queues (bytes, -q) 819200 real-time priority (-r) 0 stack size (kbytes, -s) 8192 cpu time (seconds, -t) unlimited max user processes (-u) 31321 virtual memory (kbytes, -v) unlimited file locks (-x) unlimited 

Run free, on my machine the result is like this:

 total used free shared buffers cached Mem: 4024900 606472 3418428 0 85768 366980 -/+ buffers/cache: 153724 3871176 Swap: 3998716 0 3998716 

I wrote this code to test how many threads a process can create:

#include<iostream> #include<pthread.h> #include<unistd.h> #include<stdio.h> using namespace std; #define MAX_THREAD_NUM 1100 void * threadTest(void* arg){ while(true){ sleep(5); } pthread_exit(NULL); } int main(){ for(int i = 0;i< MAX_THREAD_NUM;i++){ pthread_t tid; cout<<"create thread "<< i <<"... "<<endl; int ret = pthread_create(&tid,NULL,&threadTest,NULL); if(ret !=0){ perror("pthread_create error"); } pthread_detach(tid); } while(true){ sleep(5); } return 0; } 

The result is like this:

create thread 378... create thread 379... create thread 380... create thread 381... create thread 382... pthread_create error: Cannot allocate memory create thread 383... pthread_create error: Cannot allocate memory create thread 384... pthread_create error: Cannot allocate memory create thread 385... pthread_create error: Cannot allocate memory create thread 386... pthread_create error: Cannot allocate memory 
0

vmstat

vmstat reports report virtual memory statistics, which has information about processes, swap, free, buffer and cache memory, paging space, disk IO activity, traps, interrupts, context switches and CPU activity. With vmstat command, administrators can has instantaneous reports on memory usage.

Syntax of vmstat

vmstat -[options] [delay count] 

Example usage of vmstat

vmstat 

Found here

1

The "free" command will show you memory utilization, including what's actually being used vs what's in buffers / cache.

 # free total used free shared buffers cached Mem: 3896252 3779044 117208 0 65788 1363972 -/+ buffers/cache: 2349284 1546968 Swap: 2097144 886836 1210308 

The "dmidecode" command might give you some insight into the FSB speed.

swapon -s 

The used field will indicate the amount currently in use

Filename Type Size Used Priority /dev/sda5 partition 859436 0 -1 

Page Size :

$ getconf PAGESIZE 

(or)

$ getconf PAGE_SIZE 

Try

swapinfo or swapinfo -a 

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like