Skip to content

fix memory leak in cholmod - #733

Merged
dkarrasch merged 2 commits into
JuliaSparse:mainfrom
stevengj:patch-4
Jul 24, 2026
Merged

fix memory leak in cholmod#733
dkarrasch merged 2 commits into
JuliaSparse:mainfrom
stevengj:patch-4

Conversation

@stevengj

@stevengj stevengj commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Fix bug identified on discourse.

@stevengj stevengj mentioned this pull request Jul 6, 2026
@codecov

codecov Bot commented Jul 6, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 83.33333% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 84.35%. Comparing base (c50786b) to head (b464359).

Files with missing lines Patch % Lines
src/solvers/cholmod.jl 83.33% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #733      +/-   ##
==========================================
+ Coverage   84.34%   84.35%   +0.01%     
==========================================
  Files          13       13              
  Lines        9373     9373              
==========================================
+ Hits         7906     7907       +1     
+ Misses       1467     1466       -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dkarrasch

Copy link
Copy Markdown
Member

Can this be tested? Does this need backporting (v1.13 for sure, but v1.12 & LTS)?

@stevengj

stevengj commented Jul 6, 2026

Copy link
Copy Markdown
Contributor Author

Presumably the existing tests from #547 (cc @ranocha) cover the code to make sure it works? Not sure how to test for a memory leak?

@bbrehm

bbrehm commented Jul 6, 2026

Copy link
Copy Markdown

I verified presence of some memory leak via Base.gc_live_bytes(). That might work as a regression test.

I have not looked into the allocation path in SuiteSparse or valgrind. To be honest, I'm somewhat surprised that this allocation gets properly logged and accounted for, at all!

@ranocha

ranocha commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Thanks a lot for the fix. I am sorry for introducing this bug two years ago.

The basic method should be tested, but I am not sure whether all branches will be tested completely.

This could be a explanation for

The current method still allocates some memory on my system since we do not provide the workspace vectors Handle_Y and Handle_E. We could store them in the CHOLMOD.Factor struct. I tried that, but they were still C_NULL after the call to solve2 (when initialized with C_NULL). Thus, re-using them is not working as I understand the docs. Thus, I have not added this complexity to this PR.

noticed in #547. I guess we should at least open an issue to check whether this works correctly with the fix from this PR, and consider adding this additional optimization in another PR.

@ViralBShah

Copy link
Copy Markdown
Member

cc @rayegun

@dkarrasch dkarrasch added backport 1.12 Change should be backported to release-1.12 backport 1.13 Change should be backported to release-1.13 labels Jul 6, 2026
@stevengj

stevengj commented Jul 8, 2026

Copy link
Copy Markdown
Contributor Author

Storing the workspace vectors in CHOLMOD.Factor is happening in #727

@dkarrasch
dkarrasch merged commit 1e27ff9 into JuliaSparse:main Jul 24, 2026
10 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport 1.12 Change should be backported to release-1.12 backport 1.13 Change should be backported to release-1.13

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants