> For the complete documentation index, see [llms.txt](https://www.null-pointer.co.uk/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.null-pointer.co.uk/memory-and-cpu.md).

# Memory and CPU

### What is the heap size of my java application <a href="#what-is-the-heap-size-of-my-java-application" id="what-is-the-heap-size-of-my-java-application"></a>

```
$ java -XX:+PrintFlagsFinal -version | grep HeapSize
    uintx ErgoHeapSizeLimit                         = 0                                   {product}
    uintx HeapSizePerGCThread                       = 87241520                            {product}
    uintx InitialHeapSize                          := 190840832                           {product}
    uintx LargePageHeapSizeThreshold                = 134217728                           {product}
    uintx MaxHeapSize                              := 3040870400                          {product}
java version "1.8.0_92"
Java(TM) SE Runtime Environment (build 1.8.0_92-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.92-b14, mixed mod
```

### Native memory tracking <a href="#native-memory-tracking" id="native-memory-tracking"></a>

```
jcmd 1 VM.native_memory summary
```

### Parameters of a running JVM <a href="#parameters-of-a-running-jvm" id="parameters-of-a-running-jvm"></a>

You can use `jps`[1](https://www.null-pointer.co.uk/memory-and-cpu.html#fn_1)

```
jps -lvm
```

### Default heap size <a href="#default-heap-size" id="default-heap-size"></a>

On a Unix/Linux system, you can do [2](https://www.null-pointer.co.uk/memory-and-cpu.html#fn_2)

```
java -XX:+PrintFlagsFinal -version | grep HeapSize
```

### How much memory does my machine have <a href="#how-much-memory-does-my-machine-have" id="how-much-memory-does-my-machine-have"></a>

The best way to find out RAM information such as amount of free and used memory in the system is to open a terminal and type the following command[3](https://www.null-pointer.co.uk/memory-and-cpu.html#fn_3)

```
$ free -m
              total        used        free      shared  buff/cache   available
Mem:          11598       10364         188         634        1044         339
Swap:             0           0
```

### How many cpus does my machine have <a href="#how-many-cpus-does-my-machine-have" id="how-many-cpus-does-my-machine-have"></a>

```
$ cat /proc/cpuinfo | grep processor | wc -l
8
```

* > 1\. [Getting the parameters of a running JVM](https://stackoverflow.com/questions/5317152/getting-the-parameters-of-a-running-jvm), by Peter Lawrey (15 Mar, 2011) *stackoverflow*[ ↩](https://www.null-pointer.co.uk/memory-and-cpu.html#reffn_1)
* > 2\. [How is the default Java heap size determined?](https://stackoverflow.com/questions/4667483/how-is-the-default-java-heap-size-determined), by stones333 (14 Dec, 2012) *stackoverflow*[ ↩](https://www.null-pointer.co.uk/memory-and-cpu.html#reffn_2)
* > 3\. [How Much RAM does my Ubuntu / Fedora Linux desktop PC have?](http://www.cyberciti.biz/tips/how-much-ram-does-my-linux-system.html), (25 Apr, 2007) *nixCraft*[ ↩](https://www.null-pointer.co.uk/memory-and-cpu.html#reffn_3)
