Skip to content

Memory leak when using shortest_paths #288

@matt-wirtz

Description

@matt-wirtz

Hello,

there is a memory leak when using shortest_paths algorithm.

library(igraph)
iterations <- 1000
g <-  make_tree(n = 5000, children = 3, mode = "out")

for (i in 1:length(V(g))) { V(g)[i]$name <- ifelse(i %% 10 == 0, "home", "away")}
for (i in 1:length(E(g))) { E(g)[i]$weight <- as.integer(runif(1, 1, 10)) }

print(sum(gc()[,4]))
for (i in 1:iterations) { 
  if (i %% 100 == 0) print(sum(gc()[,4]))
  sp <- shortest_paths(g, from = 3, to = V(g)[name == "home"], 
                   mode="out", output="vpath", weights = E(g)$weight) 
  }

The memory used by the R session is displayed after every 100 calls to shortest_paths. It increases more or less steadily. When using smaller graphs it takes more iterations to make the increase obvious. I tested it on ArchLinux and Windows using igraph 1.1.2.

I came across this issue in a lager simulation and there I ended up with an R session using 3GB while all objects within the R session just needed 5MB. After drilling down I found out that the calls to shortest_paths caused the memory leaks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behaviorc code

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions