Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-90366

Improve memory tracking of private data in JS Objects in mozjs integration.

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Query Integration

      In the implementation of our custom JS Objects used with mozjs, we store data/objects associated with our JS Objects inside the private slot data region of the JS Objects. The data stored in the private slot dataregion is not tracked by the mozjs garbage collector, since it is stored as a void* and typically has not been allocated through the spidermonkey/cell allocation code.

      This is usually benign, but for cases where we have large objects in the underlying private slot data, it means that we consume more memory than the GC is aware of, and leads to the GC not being called as it should. One such example is BSONInfo. BSONInfo stores a BSONObj that was not allocated by mozjs, but could consume a significant amount of memory that is not being tracked by the GC.

      To overcome this, incorporate the use of AddAssociatedMemory/RemoveAssociatedMemory (see https://searchfox.org/mozilla-central/source/js/public/MemoryFunctions.h#72-86) to inform the GC of the additional memory usage associated with the JS Object.

            Assignee:
            Unassigned Unassigned
            Reporter:
            santiago.roche@mongodb.com Santiago Roche
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: