How to use memmap kernel parameter? - memory

I want to reserve 512 MB of RAM starting from 2GB. I have tried using memmap=512M$2G. But after restart when I used cat /proc/cmdline, it displays memmap=512MM and the system become very slow. I am using non UEFI system.

This varies with grub versions and distribution, but you probably need to add escape characters:
memmap=512M\\\$2G

Related

Since we have the virtrual memory technique, why can’t the application use 4GB memory on the 32-bit OS?

I wonder why the application can't use 4GB memory on the 32-bit OS since we use the virtrual memory technique. I know some programs like OS which should use some memory, does it mean every application must treat these programs such OS as a part of them from the point of 4 GB addressable virtrual memory.
The OS or hardware divide the address space into special purposes. E.g., Kernel and User. The logical address range assigned to these other purposes cannot be used by the application.
System Parameters can limit the size of the address space.
Quotas can limit the logical address space for a specific user or process.
Page file space can limit the logical address space for everyone.

How to programmatically tell that Linux is in PAE or non-PAE mode?

Need to create a script to check to see if the kernel is in PAE mode or not. Surely, it is not enough to just check if the /proc/cpuinfo flags have this 'pae' setting.
We must know if the PAE mechanism has actually been not only implemented, but activated as well.
Because the PAE kernel is now the new default, and that if you need a non-PAE kernel, one has to make another kernel nowadays.
In other word, how do we tell if a kernel is non-PAE on a CPU having PAE (is one of two possible conditions to test for).
Other is, how to tell if a kernel is PAE on a CPU having no PAE-support.
And there's no way to tell if CONFIG_HIGHMEM or CONFIG_PAE kernel configuration option was used in a typical secured kernel.
Usually, CONFIG_PAE can be discovered in your /boot/config-*, like this:
$ cat /boot/config-$(uname -r) | grep PAE
CONFIG_X86_PAE=y
Do you not have access to the that file?
One way is to read the CR4 register and look at bit 5. It will be 1 for PAE and 0 for no PAE. You can read that register in some code running in the kernel (e.g. a kernel driver). You may be able to write a tiny driver for this purpose. It shouldn't be very complicated.

Can a 32-bit program use more than 4GB of memory on a 64-bit OS?

Is a 32-bit program running on a 64-bit OS able to use more than 4GB of memory if available?
Short answer is: yes.
Longer answer is depends. There is a hardware support for page re-mapping, which basically gives your program a window of a few pages into a larger area of memory.
This window is however, should be managed by the program itself and will not get support from memory manager. There are examples of programs doing that like SQL on Windows.
However, in general it is a bad idea and the program should either limit itself for 4GB or move to 64bits :)
Normally you're limited to a 2GB address space, in which all your allocations and their overhead, fragmentation, etc., must fit along with memory-mapped files (which includes your program and the DLLs it uses). This effectively limits you to 1.5GB.
With special configuration, e.g. /3GB, you can make more than 2GB available to applications, but by doing so you rob the kernel of space, costing you file caching, handle capacity, etc..
On Win32, you can use more with PAE support, but it's not transparent, you have to manage it yourself.
Only by explicitly mapping 4GB ranges of memory into its address space.

Memory usage limits for programs on Windows (7)

I strongly expect this to end up as a duplication, but I can't seem to find it.
I've got a C++ program that I normally run on 64-bit MacOSX SnowLeopard.
When I try to run it on a 32-bit Windows 7, it runs out of memory. Probably, it really needs too much memory, but I want to make sure that I'm not missing some sort of option or another that allows me to squeeze out the maximum possible heap size.
32 bit Process have a 4GB memory limit, but it's spitted into 2GB for the user address space and the kernel address space.
There is a /3GB switch so that you can use 3GB for the user space and 1 GB for the kernel space. To do this you need to change a setting in the OS through boot.ini(Win 2000, XP, 2003) or the bcdedit utility(Win Vista an later). Also you need to make your exe aware of this switch linking it with the /LARGEADDRESSAWARE flag. You can do this with the editbin utility(it comes with the Windows SDK).
Other than that I'm afraid you have to make some changes to how your app runs so that it doesn't take as much memory.
According to this table, the limit per process should be 2GB or 3GB with some registry tampering. I don't think this is much different from previous versions of Windows. I recall XP limited addressable memory to 3GB.

Ubuntu 32 bit maximum address space

Jeff covered this a while back on his blog in terms of 32 bit Vista.
Does the same 32 bit 4 GB memory cap that applies in 32 bit Vista apply to 32 bit Ubuntu? Are there any 32 bit operating systems that have creatively solved this problem?
Ubuntu server has PAE enabled in the kernel, the desktop version does not have this feature enabled by default.
This explains, by the way, why Ubuntu server does not work in some hardware emulators whereas the desktop edition does
Well, with windows, there's something called PAE, which means you can access up to 64 GB of memory on a windows machine. The downside is that most apps don't support actually using more than 4 GB of RAM. Only a small number of apps, like SQL Server are programmed to actually take advantage of all the extra memory.
Yes, 32 bit ubuntu has the same memory limitations.
There are exceptions to the 4GB limitation, but they are application specific... As in, Microsoft Sql Server can use 16 gigabytes with "Physical address Extensions" [PAE] configured and supported and... ugh
http://forums.microsoft.com/TechNet/ShowPost.aspx?PostID=3703755&SiteID=17
Also drivers in ubuntu and windows both reduce the amount of memory available from the 4GB address space by mapping memory from that 4GB to devices. Graphics cards are particularly bad at this, your 256MB graphics card is using up at least 256MB of your address space...
If you can [your drivers support it, and cpu is new enough] install a 64 bit os. Your 32 bit applications and games will run fine.
There seems to be some confusion around PAE. PAE is "Page Address Extension", and is by no means a Windows feature. It is a hack Intel put in their Pentium II (and newer) chips to allow machines to access 64GB of memory. On Windows, applications need to support PAE explicitely, but in the open source world, packages can be compiled and optimized to your liking. The packages that could use more than 4GB of memory on Ubuntu (and other Linux distro's) are compiled with PAE support. This includes all server-specific software.
In theory, all 32-bit OSes have that problem. You have 32 bits to do addressing.
2^32 bits / 2^10 (bits per kb) / 2^10 (kb per mb) / 2^10 (mb per gb) = 2^2 = 4gb.
Although there are some ways around it. (Look up the jump from 16-bit computing to 32-bit computing. They hit the same problem.)
Linux supports a technology called PAE that lets you use more than 4GB of memory, however I don't know whether Ubuntu has it on by default. You may need to compile a new kernel.
Edit: Some threads on the Ubuntu forums suggest that the server kernel has PAE on by default, you could try installing that.

Resources