You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have code in an actual program that does the following in a loop:
Receive data via an asynchronous socket
Parse the data
Send the parse results back to the client
(2) creates some linked lists which (3) then converts to the network protocol. After (3), the lists from (2) are not needed, however they are kept in memory for some reason, which means that this program leaks memory indefinitely.
Test Case:
import os
import math
import lists
import strutils
proc mkleak() =
let numberOfLists = random(10)
for i in countUp(1, numberOfLists):
var leakList = initDoublyLinkedList[string]()
let numberOfLeaks = random(100)
for j in countUp(1, numberOfLeaks):
let leakSize = random(4096)
let leaked = newString(leakSize)
leakList.append(leaked)
proc mkManyLeaks() =
while true:
mkleak()
echo GC_getStatistics()
# Force a full collection. This should free all of the
# lists and bring the memory usage down to a few MB's.
GC_fullCollect()
# Surprise! It didn't.
echo GC_getStatistics()
sleep(1000)
mkManyLeaks()
The text was updated successfully, but these errors were encountered:
For anyone coming here depressed that you can no longer write long running programs in Nim - this issue is absent in all GCs except for the default (refc). Just compile your program with one of:
I have code in an actual program that does the following in a loop:
(2) creates some linked lists which (3) then converts to the network protocol. After (3), the lists from (2) are not needed, however they are kept in memory for some reason, which means that this program leaks memory indefinitely.
Test Case:
The text was updated successfully, but these errors were encountered: