Stressing the memory of linux server - bash

I used the stress command to stress the CPU of the Linux server(CentOS). Following is the command used.
sudo stress --cpu 4 --timeout 3600
Also I want to do the stress test for the Server memory using such a bash command. The answer here is not supported with bash commands. I am aware of the tools that can be used to stress the memory as stated here. But I want to write a bash script to do stressing.
Does memory stressing affect for virtual memory or only physical memory?

Virtual memory is when some disk space is allocated for this to be more RAM, but would be slower as you are using the hard drive. I would not stress test the virtual memory, if you cannot stop a stress test using the virtual memory, then i would disable virtual memory temporarily, and then after your stress test on the RAM, you can enable the virtual memory again.

Related

How can a 4GB process run on only 2 GB RAM?

Given a 32-bit/64-bit processor can a 4GB process run on 2GB RAM. Will it use virtual memory or it wont run at all?
This is HIGHLY platform dependent. On many 32bit OS's, no single process can ever use more than 2GB of memory, regardless of the physical memory installed or virtual memory allocated.
For example, my work computers use 32bit Linux with PAE (Physical Address Extensions) to allow it to have 16GB of RAM installed. The 2GB per process limit still applies however. Having the extra RAM simply allows me to have more individual processes running. 32bit Windows is the same way.
64bit OS's are more of a mixed bag. 64bit Linux will allow individual processes to map memory well in excess of 32GB (but again, varies from Kernel to Kernel). You will be limited only by the amount of Swap (Linux virtual memory) you have. 64bit Windows is a complete crap shoot. Certain versions will only allow 2GB per process, but most will allow >32GB limited only by the amount of Page File the user has allocated.
Microsoft provides a useful table breaking down the various memory limits on various OS versions/editions. Unfortunately there is no such table that I can find with cursory searching for Linux since it is so fragmented.
Short answer: Depends on the system.
Most 32-bit systems have a limitation of 2GB per process. If your system allows >2GB per process, then we can move on to the next part of your question.
Most modern systems use Virtual Memory. Yet, there are some constrained (and various old) systems that would just run out of space and make you cry. I believe uClinux supports both MMU and MMU-less architectures. Most 32-bit processors have a MMU (a few don't, see ARM Cortex-M0) and a handful of 16-bit or 8-bit have it as well (see Atmel ATtiny13A-MMU and Atari MMU).
Any process that needs more memory than is physically available will require a form of Memory Swap (e.g., a partition or file).
Virtual Memory is divided in pages. At some point, a page reside either in RAM or in Swap. Any attempt to access a memory page that's not loaded in RAM will trigger an interruption called Page Fault, which is handled by the kernel.
A 64-bit process needing 4GB on a 64-bit OS can generally run in 2GB of physical RAM, by using virtual memory, assuming disk swap space is available, but performance will be severely impacted if all of that memory is frequently accessed.
A 32-bit process can't address exactly 4GB of memory in practice (some address space overhead is required by the operating system), so it won't run. Depending on the OS, it can probably run a process that needs > 2GB and < 3-4GB.

Jenkins consumes a very large portion of physical memory

I have installed Jenkins on a virtual OS. Whenever I start the Jenkins service the physical memory goes up to 94%. Then it never reduces. So my system becomes very slow and unresponsive. As a result the Jenkins web page becomes slow. I have allocated 4GB for RAM. Is there any way to speed up my machine to restrict the memory use for Jenkins?

Does JVM memory management work the same on Windows and Linux?

My original question is that, is this technically rational to check the required heap-size of my Java program on Windows 7, via VisualVM, and come to this conclusion that the program will require the same amount of heap on Linux(RedHat) as well?
I don't know how the system(OS or even CPU and RAM), affect memory management of JVM.
well, the windows is my development system with 4GB of RAM and a Core 2 Due CPU, however the
Linux is the production system with 32GB of RAM and multiple powerfull processors,
Actually, my concern is that the program on Linux might need more memory. less is ok.

CPU utilization of virtual machine

I have one physical machine which has 4 CPUs. I want to have some VM on it. The goal of my work is finding CPU utilization. But I am confused how the CPU usage of VMs and physical machine are related. Is there a relation between CPU utilization of VMs and physical machine? How should I measure the CPU utilization of each VM? What is the CPU utilization of the physical machine?
If you are using any xen enabled hypervisor, you can use xenmon or xentop in your Dom0(physical machine) to check the utilization or performance of your VMs.
You can do so by typing xentop(it is /usr/sbin/xentop in my case) on the command line which will give you all the info you are looking for. Alternatively you can use xenmon -l command (/usr/sbin/xenmon.py python script) in my case which shows all the live information about your VMs.

Changing Memory& CPU usage in Windows 7

I want to test with a windows machine with low performance hard wares. Unfortunately I have a higher end machine. Is there a way to limit the performance of CPU and RAM memory usage? Can I do it through any other software or is there way through windows OS itself?
You can use VMWare to limit memory. You won't be able to limit processor speed in your virtual machine but you can assign only 1 core to it.
Try CPUKiller - software for limiting CPU performance.
You can use the truncatememory boot options to limit the amount of memory available usable by Windows. See BCDEdit /set (MSDN)

Resources