# @mlabs-haskell/cardano-serialization-lib-gc

> This is a small wrapper for managing garbage collection for @emurgo/cardano-serialization-library

Latest version **13.2.0** (published 2024-11-18) · ISC license · 0 weekly downloads

## Install

```sh
npm install @mlabs-haskell/cardano-serialization-lib-gc
pnpm add @mlabs-haskell/cardano-serialization-lib-gc
yarn add @mlabs-haskell/cardano-serialization-lib-gc
bun add @mlabs-haskell/cardano-serialization-lib-gc
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 13.2.0 |
| Published | 2024-11-18 |
| First published | 2024-01-07 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 3 |
| Unpacked size | 29.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | klntsky |
| Maintainers | emmarichardson, errfrom, oskargreda, amirmrad, klntsky, nalane, chase-mlabs, neil-mlabs |

## Links

- npm: https://www.npmjs.com/package/@mlabs-haskell/cardano-serialization-lib-gc
- Repository: https://github.com/mlabs-haskell/cardano-serialization-lib-gc
- Homepage: https://github.com/mlabs-haskell/cardano-serialization-lib-gc#readme
- Issues: https://github.com/mlabs-haskell/cardano-serialization-lib-gc/issues
- npm.io page: https://npm.io/package/@mlabs-haskell/cardano-serialization-lib-gc

## Dependencies (3)

- [@mlabs-haskell/csl-gc-wrapper](https://npm.io/package/@mlabs-haskell/csl-gc-wrapper.md) 1.0.2
- [@emurgo/cardano-serialization-lib-nodejs](https://npm.io/package/@emurgo/cardano-serialization-lib-nodejs.md) 13.2.0
- [@emurgo/cardano-serialization-lib-browser](https://npm.io/package/@emurgo/cardano-serialization-lib-browser.md) 13.2.0

## Recent versions

- 13.2.0 (latest) — 2024-11-18
- 12.0.0 — 2024-08-28
- 12.0.0-beta.10 — 2024-08-26
- 12.0.0-beta.2 — 2024-07-03
- 12.0.0-alpha.31 — 2024-06-10
- 1.0.10 — 2024-04-16
- 1.0.9 — 2024-02-14
- 1.0.8 — 2024-01-09
- 1.0.7 — 2024-01-07
- 1.0.6 — 2024-01-07

## README

# cardano-serialization-lib-gc

This is a small ESM 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.

Example usage with NodeJS:

```javascript
import * as lib from "@mlabs-haskell/cardano-serialization-lib-gc";

function fixture() {
  lib.PlutusData.new_bytes(
    new Uint8Array(Array(10000000).fill(0))
  );
}

setInterval(() => {
  for (let i = 0; i < 10; i++) {
    fixture()
  }
}, 500) // collection of unused objects will trigger `free()` calls
// for the corresponding WASM-allocated memory
```

This code will not leak, but if you try to use the original package, the memory usage will steadily grow.

If you want to use this library as a CommonJS module, use legacy [csl-gc-wrapper](https://github.com/mlabs-haskell/csl-gc-wrapper) instead.

---
_Source: https://npm.io/package/@mlabs-haskell/cardano-serialization-lib-gc · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
