Memory Leak in graph.union
There seems to be a memory leak in graph.union. When running the sample code below, I get the following memory profile:

import random
import numpy as np
from igraph import Graph
if __name__ == '__main__':
for i in range(200):
num_nodes = 100
num_edges = 100000
graph = Graph(num_nodes)
edges = [
random.choices(range(num_nodes), k=2)
for _ in range(num_edges)
]
# Create a new graph with the same edges
attributes = {"test": np.arange(len(edges))}
new_graph = Graph(edges=edges, edge_attrs={"test": np.arange(len(edges))})
# Generate a union of the 2 graphs
union_graph = graph.union(new_graph)
I'm not sure if this issue is related to the python side of igraph, or if it's in the c code. Note: this was tested with python-igraph==0.9.10
Thanks, this is interesting as we have recently fixed a leak in Graph.union in 1593c14d8e9b25b876a04c2a110d12edda2211ae and this is already in 0.9.10. Let me try to reproduce this on my end.
Let me know if you need me to try another LSan run with this code.
For what it's worth, putting this through LSan reveals no problems (except for a small leak in numpy RNG, which is certainly not the cause of this).
I think this will be a reference counting error, i.e. we are holding on to an object when we no longer need it, and it gets freed only when Python exits.
Indeed it was a refcount error; it is now fixed in 043515f (develop) and 764de38 (master).
@Maxyme Can you install python-igraph from source and test whether it solves the problem for you? (See here for instructions). If you cannot compile things from source, that's okay, let me know what OS you are using and which Python version and I'll send you a precompiled wheel to test.
@ntamas awesome, I just checked with the latest version and can confirm that the leak is fixed:

Thanks for the feedback. This will be released in 0.9.11 or 0.10.0, whichever comes first.