https://github.com/mlabs-haskell/csl-gc-wrapper
https://github.com/mlabs-haskell/csl-gc-wrapper
Last synced: 11 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/mlabs-haskell/csl-gc-wrapper
- Owner: mlabs-haskell
- Created: 2023-01-16T12:53:39.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2024-07-14T15:36:51.000Z (about 2 years ago)
- Last Synced: 2025-03-16T13:42:02.077Z (over 1 year ago)
- Language: JavaScript
- Size: 9.77 KB
- Stars: 0
- Watchers: 6
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
### csl-gc-wrapper
This is a small library that provides a wrapper for managing garbage collection for [cardano-serialization-library](https://github.com/Emurgo/cardano-serialization-lib). It does this by using a FinalizationRegistry object to keep track of objects that are no longer in use, and calling the `free()` method on them when they are finalized.
Most likely you would want to use [a vendored version of CSL with this wrapper applied](https://github.com/mlabs-haskell/cardano-serialization-lib-gc).
Example usage:
```javascript
const csl = require("@emurgo/cardano-serialization-lib-browser");
const wrappedCsl = require('@mlabs-haskell/csl-gc-wrapper')(csl)
function fixture() {
const arr = new Uint8Array(Array(10000000).fill(0));
const pd = lib.PlutusData.new_bytes(arr);
}
setInterval(() => {
for (let i = 0; i < 10; i++) {
fixture()
}
}, 500) // gc will trigger proxies and underlying pointers
```