-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Description
The descriptorCache in observableObject.ts appears to trade a small amount of memory for performance when initializing an observable, creating one cached descriptor for every unique object key that mobx sees.
We encountered a situation where a library was using a plain java object as a Map, with UUIDs as the key. This wasn't causing any problems for end users, but on our SSR server the infinitely-many different UUIDs resulted in Mobx caching infinitely-many descriptors. This leaked memory with no way to recover it.
While we were able to patch the library to use an actual Map object to coax mobx into using ObservableMap instead of the ObservableObjectAdministration, it would be nice to have a way to either disable the descriptorCache entirely or have a utility method for clearing it.