Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Information heap size

What information can I obtain from the performance.memory object in Chrome?
What do these numbers mean? (are they in kb's or characters)
What can I learn from these numbers?

Example values of performance.memory

MemoryInfo {
  jsHeapSizeLimit: 793000000,
  usedJSHeapSize: 10000000,
  totalJSHeapSize: 31200000
}
like image 241
Rick Hoving Avatar asked Jan 20 '14 16:01

Rick Hoving


People also ask

What is the size of heap?

The default heap size is 1 MB. The linker rounds up the specified value to the nearest 4 bytes. The optional commit argument specifies the amount of physical memory to allocate at a time. Committed virtual memory causes space to be reserved in the paging file.

How do you determine heap size?

It is recommended to increase the Java heap space only up to one-half of the total RAM available on the server. Increasing the Java heap space beyond that value can cause performance problems. For example, if your server has 16 GB of RAM available, then the maximum heap space you should use is 8 GB.

Is heap size same as RAM?

The RAM is the physical memory of your computer. Heap memory is the (logical) memory reserved for the heap. So, only part of the RAM is used as heap memory and heap memory doesn't have to be fully loaded into RAM (e.g. part of it may be swapped to disc by the OS).


2 Answers

What information can I obtain from the performance.memory object in Chrome?

The property names should be pretty descriptive.

What do these numbers mean? (are they in kb's or characters)

The docs state:

The values are quantized as to not expose private information to attackers.

See the WebKit Patch for how the quantized values are exposed. The tests in particular help explain how it works.

What can I learn from these numbers?

You can identify problems with memory management. See http://www.html5rocks.com/en/tutorials/memory/effectivemanagement/ for how the performance.memory API was used in gmail.

like image 160
Bergi Avatar answered Sep 28 '22 02:09

Bergi


The related API documentation does not say, but my read judging by the numbers you shared and what I see on my machine is that the values are in bytes.

A quick review of the code to which Bergi linked - regarding the values being quantized - seems to support this - e.g. float sizeOfNextBucket = 10000000.0; // First bucket size is roughly 10M..

The quantized MemoryInfo properties are mostly useful for monitoring vs. determining the precise impact of operations on memory. A comment in the aforementioned linked code explains this well I think:

86 // We quantize the sizes to make it more difficult for an attacker to see precise
87 // impact of operations on memory. The values are used for performance tuning,
88 // and hence don't need to be as refined when the value is large, so we threshold
89 // at a list of exponentially separated buckets.

Basically the values get less precise as they get bigger but are still sufficiently precise for monitoring memory usage.

like image 28
J0e3gan Avatar answered Sep 28 '22 02:09

J0e3gan