I want to inspect memory. In Linux
I can probably just browse through /dev/mem
, but how to view system memory at a specific location on the Mac though?
MacOS – Command line program to show contents of memory location
command linemacosmemory
Related Question
- MacOS – How to diagnose the Python program being killed due to an out-of-memory error
- Command line in AppleScript
- MacOS – How to get cpu/memory usage from command line output
- MacOS – How to calculate used memory on Mac OS by command line
- MacOS – Why is “Real Memory” greater than “Memory” for kernel_task process
- MacOS – Get per process user and system CPU time on OSX via command line
- Change output format of “top” command in Mac OS for memory usage
- MacOS – Using command line how to open a specific section of GUI System Preferences
Best Answer
Contrary to your assumption you cannot actually just browse through /dev/mem on a default Linux. A few years ago, the device was made restricted by default on Linux so that only very limited areas of memory are available this way. You can remove the restriction only by recompiling the kernel.
On macOS the device is completely restricted by default for similar security reasons. You can however enable it using a boot time parameter.
Explicitly enable this by rebooting your Mac, holding the Command and R keys to start up in Recovery Mode. Then open the Utilities menu and select Terminal. From the Terminal you need to run the following command:
After rebooting you'll find that you have new /dev/mem and /dev/kmem (kernel memory) device files.
You'll need to use sudo or be root to access the devices. The /dev/mem device is addressed by physical memory address, and /dev/kmem by virtual memory address.