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
Memory leak with set #12052
Comments
Well |
Well, from what I could tell the allocator doesn't handle this very well. Do you have any ideas why that might be? |
Memory usage with Boehm is even higher for me, that rules out fragmentation. You have 101 bots each has a table with 64 entries, each entry takes roughly 8KB, total memory usage about 50.648MiB. Floating garbage and other stuff makes it 82MiB on my machine. Perfectly acceptable except that tables's |
Is it acceptable? This is quite a gotcha that might make some feel that
there is a bug in Nim causing a mem leak. We should at least document this
well.
…On Wed, 18 Sep 2019 at 11:43, Andreas Rumpf ***@***.***> wrote:
Closed #12052 <#12052>.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#12052?email_source=notifications&email_token=AAB4G67CCFKLRKG2QDQPLKLQKIA4PA5CNFSM4IPO7722YY3PNVWWK3TUL52HS4DFWZEXG43VMVCXMZLOORHG65DJMZUWGYLUNFXW5KTDN5WW2ZLOORPWSZGOTWEW6QY#event-2643029827>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAB4G64OKE3TGPYQC4JZAE3QKIA4PANCNFSM4IPO772Q>
.
|
There is no leak and here is another workaround: proc runBots() =
var bots: seq[Bot]
for i in 0 .. 100:
bots.add(Bot(queuedEvents: initTable[BotEventKind, BotEvent](8))) |
I have been investigating the high memory usage of my application for some days now. One cause that I've just found is
set
. The memory grows unbounded in my program if I use it.I've tried to reproduce this, but the best I could do is to get an application that uses a lot of memory (the memory usage doesn't grow). The example below uses 75MB of memory on my MacBook, and a simple s/set/HashSet/ makes that decrease to 1.5MB so there is surely something wrong here.
As far as my application goes, switching to HashSet also fixes the unbounded growth.
Example
Current Output
Memory usage is 75MB
Expected Output
Memory usage should be lower, or alternatively we should disallow usage of
set
this way to prevent memory leaks (or perceived memory leaks).Possible Solution
Use HashSet instead
Additional Information
The text was updated successfully, but these errors were encountered: