Closed xD0135 closed 2 years ago
This is not specific to Vex, but with the V programming language. As -autofree
becomes more stable, less leaks should happen. For now you can compile with -gc boehm
, which will take a minor performance hit, but it'll eliminate leaks.
Beware, garbage collectors and Valgrind don't go well together though.
Reading through V's documentation on Memory management we see the following:
Note: right now autofree is hidden behind the -autofree flag. It will be enabled by default in V 0.3. If autofree is not used, V programs will leak memory.
Note 2: Autofree is still WIP. Until it stabilises and becomes the default, please compile your long running processes with -gc boehm, which will use the Boehm-Demers-Weiser conservative garbage collector, to free the memory, that your programs leak, at runtime.
Compiling the program with the recommended options:
$ v -gc boehm -o vex-server server.v
Take the initial memory allocation:
$ pmap $(pgrep vex-server) | grep total
total 130576K
Run the benchmark with pewpew
again and look at the memory allocation after the load test:
$ pmap $(pgrep vex-server) | grep total
total 130576K
We can see this is no longer an issue. Thanks!
Thanks for creating this project. While performing a simple test to verify the speed and resource consumption of your framework I discovered critical memory leaks that would prevent anyone from using this framework in a production environment. Details are below.
System info:
Simple server:
Compile and start the server:
Take the initial memory allocation:
Execute a simple load test (I'm using pewpew here)
Take the memory allocation after the load test:
You can see the memory spiked from ~8MB to ~835MB in just 30 seconds of running the load test with ~200 requests/sec.
Furthermore, repeating the above tests with Valgrind indeed confirms the leaks. First start the server with valgrind then run the benchmark with
pewpew
once again:With Valgrind, what you want to see to ensure no memory leaks are found is the following output: