Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove clib *newFromFile from MATLAB / fix memory leaks #1754

Merged
merged 12 commits into from
Aug 5, 2024

Conversation

ischoegl
Copy link
Member

@ischoegl ischoegl commented Aug 3, 2024

Changes proposed in this pull request

  • Remove clib's *_newFromFile constructors from MATLAB; use pathways using Solution exclusively instead
  • Fix memory leak in clib where automatically added adjacent phases could not be removed
  • Make MATLAB Interface.adjacent consistent with Python version (select phase by name rather than index)
  • Fix ambiguous references that will lead to memory leaks (going back to Smart clib cabinets / add Solution to clib API #1448)

If applicable, fill in the issue number this pull request is fixing

Resolves #1756
Partially addresses Cantera/enhancements#199

Example

New in experimental MATLAB:

surf = Interface('ptcombust.yaml', 'Pt_surf');
gas = surf.adjacent('gas');

Checklist

  • The pull request includes a clear description of this code change
  • Commit messages have short titles and reference relevant issues
  • Build passes (scons build & scons test) and unit tests address code coverage
  • Style & formatting of contributed code follows contributing guidelines
  • The pull request is ready for review

@ischoegl ischoegl added the Matlab label Aug 3, 2024
Copy link

codecov bot commented Aug 3, 2024

Codecov Report

Attention: Patch coverage is 72.72727% with 18 lines in your changes missing coverage. Please review.

Project coverage is 73.11%. Comparing base (bb3f51d) to head (66f8ef5).

Files Patch % Lines
src/clib/ct.cpp 75.00% 10 Missing and 2 partials ⚠️
src/clib/Cabinet.h 66.66% 3 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1754      +/-   ##
==========================================
- Coverage   73.12%   73.11%   -0.01%     
==========================================
  Files         381      381              
  Lines       54134    54175      +41     
  Branches     9224     9226       +2     
==========================================
+ Hits        39587    39612      +25     
- Misses      11589    11602      +13     
- Partials     2958     2961       +3     

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

@ischoegl ischoegl added the clib label Aug 3, 2024
Ensure that interface is consistent with Python API.
@ischoegl ischoegl marked this pull request as ready for review August 3, 2024 17:16
@ischoegl ischoegl requested a review from a team August 3, 2024 17:19
@ischoegl ischoegl force-pushed the remove-fromFile branch 2 times, most recently from 2f736e4 to ed4e269 Compare August 4, 2024 14:37
@ischoegl ischoegl changed the title Remove clib *newFromFile from MATLAB Remove clib *newFromFile from MATLAB / fix memory leaks Aug 4, 2024
@ischoegl
Copy link
Member Author

ischoegl commented Aug 4, 2024

Added a fix for #1756: while the issue was pre-existing, this PR surfaced some symptoms, where incorrect Cabinet entries were deleted when Solution destructors were called. The PR is (again) ready for review.

PS: force-push was only to fix typos in commit messages / prevent CI failures.

Copy link
Member

@speth speth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @ischoegl. This looks mostly good to me. Just had a couple of small suggestions.

interfaces/matlab_experimental/Base/Solution.m Outdated Show resolved Hide resolved
src/clib/Cabinet.h Outdated Show resolved Hide resolved
src/clib/ct.cpp Outdated Show resolved Hide resolved
test/clib/test_clib.cpp Outdated Show resolved Hide resolved
Add object parents to Cabinet, which are used to disambiguate objects
that are created automatically, for example ThermoPhase / Kinetics /
Transport that are instantiated together with new Solution objects.
@ischoegl
Copy link
Member Author

ischoegl commented Aug 4, 2024

Thanks, @ischoegl. This looks mostly good to me. Just had a couple of small suggestions.

Thanks for the prompt review! I think it's all taken care of.

@speth speth merged commit 9d0e54a into Cantera:main Aug 5, 2024
49 of 50 checks passed
@ischoegl ischoegl deleted the remove-fromFile branch August 5, 2024 01:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ambiguous references in clib's Cabinet<M>::index
2 participants