Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible memory leak? #488

Open
saul-jb opened this issue Apr 8, 2024 · 0 comments
Open

Possible memory leak? #488

saul-jb opened this issue Apr 8, 2024 · 0 comments

Comments

@saul-jb
Copy link
Contributor

saul-jb commented Apr 8, 2024

I have found that there seems to be far more memory allocation in Helia than what is expected when persistent stores are used, the allocation seems to be about equal with the import size so I think it is not freeing up buffer memory somewhere.

I have found 2 cases where this happens - importing local data into Helia & fetching remote data into Helia. The following examples show this first case.

This allocates excess memory:

const helia = await createHelia({
  blockstore: new FsBlockstore('...'),
  datastore: new FsDatastore('...')
})
const ufs = unixfs(helia)

await all(ufs.addAll(globSource('...', '*')))

This does not allocate excess memory:

const ufs = unixfs({ blockstore: new FsBlockstore('...') })

await all(ufs.addAll(globSource('...', '*')))

Is this a mistake on my part, an expected result or a memory leak?

To make it easy to replicate I have made a repo that illustrates these examples (at least on my machine): https://github.com/saul-jb/helia-memory-leak

I have tested it with both node v18.18.2 & v20.7.0.

As far as I can tell from my own debugging so far the problem lies somewhere in Helia's BlockStorage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant