Closed benStre closed 10 months ago
@jonasstrehle this is a very essential part of the DATEX runtime - it would be great if you could also test it out with some eternal value examples in a UIX base project (Datex.Storage.printSnapshot()
for verification) - and also make sure this change does not break any existing projects (the probability is very low)
Closes https://github.com/unyt-org/datex-core-js-legacy/issues/53
This PR implements a garbage collection system for the DATEX pointer storage. This is a completely separate GC system from the runtime GC, and it is still a quite naive implementation, but it is essential for storage memory management.
The GC is not specific for a storage location, but works with all storage locations (Databases, local storage, indexed db) that implement the
StorageLocation
API. It works simultaneously across all storage locations.Background: When we assume that all eternal pointers exist for "eternity", we don't need any kind of automatic storage management - pointers are added to the storage and updated, but never deleted. Before this PR, a developer could explicitly delete pointers from the storage, but they were not removed when they were no longer needed. This is a big problem for huge collections like maps and sets with lots of volatile, changing data (e.g. temporary log entries).
The basic idea for the new storage GC is to use a basic reference counting (RC) system.
Addtional new features:
Datex.Storage.printSnapshot()
can be used for storage analyis and debuggingInitial storage allocations when running
Datex.Storage.printSnapshot()
in a new UIX base project: