Skip to content

Memory Leak in graph.union #534

@Maxyme

Description

@Maxyme

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

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

Metadata

Metadata

Assignees

Labels

todoTriaged for implementation in some unspecified future version

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions