Question

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
}
Was it helpful?

Solution

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.

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top