Extend Memory with Swap - Testing newlly added memory

This article is part 3 of the series Not Enough Memory? Extend Memory with Swap

Testing swap

Now , Let's test that we extend our memory:

free command - Find available memory
 main@work:~# sudo free -m
               total        used        free      shared  buff/cache   available
 Mem:            488         150           6           9         332         300
 Swap:           749           0         749

Now, there is ~300MB free available memory and ~750MB of swap memory. Thus, we can allocate easily ~1000MB.

Test memory allocation
 root@lamp:~# ./memory-test.py 750
 success =>  750MB was allocated
 root@lamp:~# ./memory-test.py 1000
 success => 1000MB was allocated

Summery

This method can be used to run programs which require more memory than the installed in the machine. However, there is a performance penalty as the system has to read some of the memory from and write it to the slower disk device.