v icon indicating copy to clipboard operation
v copied to clipboard

veb: memory leak

Open esquerbatua opened this issue 1 year ago • 2 comments

Describe the bug

veb leaks memory, also maybe picoev

Reproduction Steps

With this code:

module main

import veb { Result }

pub struct Context {
	veb.Context
}

pub struct App {
}

fn main() {
	mut app := App{}
	veb.run_at[App, Context](mut app, veb.RunParams{
		host: '0.0.0.0'
		family: .ip
	}) or { panic(err) }
}

fn (app &App) index(mut ctx Context) Result {
	return ctx.json('')
}

compile it with: v -cg -cc gcc -keepc -gc none /home/esquerbatua/git/breakV/jsonx.v -o vebLeak run it with: heaptrack ./vebLeak make a few requests and close the app, then run: heaptrack --analyze <generated .zst file>

Expected Behavior

Run without any memory leak

Current Behavior

Memory leaks, even with boehm.

Possible Solution

Manual free in vlib functions of picoev and veb?

Additional Information/Context

No response

V version

V full version: V 0.4.7 01fd719.a63d349

Environment details (OS name and version, etc.)

V full version: V 0.4.7 01fd719.a63d349 OS: linux, Ubuntu 24.04.1 LTS Processor: 16 cpus, 64bit, little endian, AMD Ryzen 7 7840HS w/ Radeon 780M Graphics

getwd: /home/esquerbatua/git/v vexe: /home/esquerbatua/git/v/v vexe mtime: 2024-08-31 19:03:12

vroot: OK, value: /home/esquerbatua/git/v VMODULES: OK, value: /home/esquerbatua/.vmodules VTMP: OK, value: /tmp/v_1000

Git version: git version 2.43.0 Git vroot status: weekly.2024.35-7-ga63d3493 .git/config present: true

CC version: cc (Ubuntu 13.2.0-23ubuntu4) 13.2.0 thirdparty/tcc status: thirdparty-linux-amd64 0134e9b9

[!NOTE] You can use the 👍 reaction to increase the issue's priority for developers.

Please note that only the 👍 reaction to the issue itself counts as a vote. Other reactions and those to comments will not be taken into account.

esquerbatua avatar Aug 31 '24 19:08 esquerbatua

generated C code of the example and the heaptrack file of the test c_and_zst.zip

esquerbatua avatar Aug 31 '24 19:08 esquerbatua

How curious, it seems that there are no more memory leaks, I keep it open until veb parallel is complete and I check again.

esquerbatua avatar Sep 26 '24 16:09 esquerbatua