Opened 4 years ago

Closed 4 years ago

#24660 closed defect (fixed)

Memory leak in SubgraphSearch

Reported by: Konrad127123 Owned by:
Priority: major Milestone: sage-8.2
Component: graph theory Keywords: memory leak, SubgraphSearch
Cc: Merged in:
Authors: Konrad K. Dabrowski Reviewers: David Coudert
Report Upstream: N/A Work issues:
Branch: 77b8490 (Commits, GitHub, GitLab) Commit: 77b84909751cc78971a686854266b8b371415dc9
Dependencies: Stopgaps:

Status badges

Description (last modified by Konrad127123)

In SubgraphSearch? in generic_graph_pyx.pyx

cinit contains the line: self.tmp_array = <int *> sig_malloc( * sizeof(int))

but dealloc is missing the line: sig_free(self.tmp_array)

This leads to a memory leak, which can be demonstrated with:

for i in xrange(1,1000000):
    if i%10000==0:

Currently, the memory usage keeps increasing (about 32 bytes per iteration of the loop). With the line added, the memory usage is constant.

Change History (6)

comment:1 Changed 4 years ago by Konrad127123

  • Authors set to Konrad K. Dabrowski
  • Component changed from PLEASE CHANGE to memleak
  • Description modified (diff)
  • Keywords memory leak SubgraphSearch added
  • Type changed from PLEASE CHANGE to defect

comment:2 Changed 4 years ago by Konrad127123

  • Branch set to u/Konrad127123/memory_leak_in_subgraphsearch

comment:3 Changed 4 years ago by Konrad127123

  • Commit set to 77b84909751cc78971a686854266b8b371415dc9
  • Description modified (diff)
  • Status changed from new to needs_review

New commits:

77b8490Add missing free in SubgraphSearch.

comment:4 Changed 4 years ago by Konrad127123

  • Component changed from memleak to graph theory

comment:5 Changed 4 years ago by dcoudert

  • Reviewers set to David Coudert
  • Status changed from needs_review to positive_review

Right. Thanks.

That's a typical example in which the memory allocator of sage.ext.memory_allocator.pxd could ease our life. See examples in src/sage/graphs/mcqd.pyx and src/sage/graphs/distances_all_pairs.pyx and src/sage/graphs/centrality.pyx and src/sage/graphs/base/static_sparse_graph.pyx. But your fix is OK.

comment:6 Changed 4 years ago by vbraun

  • Branch changed from u/Konrad127123/memory_leak_in_subgraphsearch to 77b84909751cc78971a686854266b8b371415dc9
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.