nikita-volkov / stm-containers

Containers for STM
http://hackage.haskell.org/package/stm-containers
MIT License
67 stars 13 forks source link

Question: Does `delete` actually free memory? #33

Open EggBaconAndSpam opened 1 year ago

EggBaconAndSpam commented 1 year ago

Hi!

I'm considering using StmContainers.Set ObjectId to implement per-object locking. Since we are creating and locking very many different objects over time this Set will potentially leak memory. Hence my question:

Does StmContainers.Set.delete actually free memory? In other words, is the memory residence of a StmContainer bounded by some constant factor times StmContainers.Set.size, or will each deleted object result in a sort of 'tombstone' and take up memory indefinitely?

For context: the ttrie library implements Control.Concurrent.STM.Map which seems to be largely equivalent to StmContainers.Map, but that suffers from delete potentially increasing the memory used.

Thanks!

nikita-volkov commented 1 year ago

Hi! There's no such issue here. Delete actually deletes records.

I recommend reporting the memory leak as a bug to the mentioned library.