Open AndreaAstronaut opened 5 days ago
Hi @AndreaAstronaut, thanks a lot for the report and your detailed investigation! You’re right, there are memory leaks in the lines you mention.
I’ve pushed a fix to the fix-memory-leaks branch.
Hi @johannessen thank you for the quick turnaround! I can confirm no memory leak for me with the fix.
To reproduce the issue I am using the movies database available to download here: https://github.com/neo4j-graph-examples/movies
This is the script:
Running above the way it is gives me a memory growth of 500 KiB every 10 seconds.
Running above with the commented-out lines instead (stream->field_names instead of $stream_fetch_next) there is zero memory growth.
I managed to trace the problem down to the following line in fetch_next: https://github.com/majensen/perlbolt/blob/4e5e932ae1ef9c928bf03b36bdb896fc4aed2abf/lib/Neo4j/Bolt/ResultStream.xs#L49
From this function the memory leak seems to be coming from the following line for the examples I tried: https://github.com/majensen/perlbolt/blob/4e5e932ae1ef9c928bf03b36bdb896fc4aed2abf/lib/Neo4j/Bolt/CTypeHandlers.xs#L345
From this function it seems to be coming from the following line:
https://github.com/majensen/perlbolt/blob/4e5e932ae1ef9c928bf03b36bdb896fc4aed2abf/lib/Neo4j/Bolt/CTypeHandlers.xs#L312
I encountered this on Oracle Linux 7 running Neo4j 5.13 and Perl 5.16.3. Neo4j::Bolt 0.4203 and Neo4j::Client 0.46 (also tried 0.52 with the same outcome).
I verified this is also happening on Oracle Linux 8 with Perl version 5.38.2 and the same versions of Neo4j::Bolt and Neo4j::Client.