Closed LouCle closed 5 years ago
If you plan to add a bunch of free
's, I wouldn't recommend doing it.
Soon V will automatically handle most of these cases.
But the V compiler will be compiled with a special flag, so that there are 0 frees in order to achieve the best performance.
Could you perhaps elaborate on how V plans to automatically handle these cases? From my limited understanding init_consts
seems to be generated by the compiler so I assume it needs to be handled on an ad-hoc basis.
@medvednikov Valgrind on c artifact (compiler.c) informs us of following memory leaks when running REPL and then immediately killing it after start.
A good chunk of them are within
init_consts
Loss record 21 of 23 (1000 bytes) is due to
g_str_buf
being allocated 1000 bytes. This was also pointed out by the person who wrote the blogpost about V.Loss record 20 of 23 (256 bytes) is inside
run_repl()
in main.v, but appears to be stem from theos.get_line
function.Loss record 23 of 23 (2240 bytes) stems from the malloc inside array_repeat in builtin array.v (and is of course variable to nr_repeats and elm_size).
Loss record 22 of 23 (1536 bytes) is the
_push
function also inside array.v. (and is also variable to the arguments)The following is from running
println('hello')
inside REPL and then immediatelly killing the V process.I'm gonna spend some time going through these leaks. I'll link all relevant PRs to this issue. I recommend that all other contributors help out patching these up.