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

Address bad memory freeing related to polar cap #3028

Merged
merged 1 commit into from
Apr 5, 2020
Merged

Conversation

PaulWessel
Copy link
Member

See forum background. This PR fixes the issue by assigning free_memory after add_pole has been finalized.

See for background.  This PR fixes the issue.
Copy link
Contributor

@KristofKoch KristofKoch left a comment

Choose a reason for hiding this comment

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

My example runs now as expected. No more crash. Thank you @PaulWessel and @joa-quim !

@PaulWessel
Copy link
Member Author

One of you need to hit the review button and approve.

@PaulWessel PaulWessel requested a review from seisman April 5, 2020 21:32
Copy link
Contributor

@KristofKoch KristofKoch left a comment

Choose a reason for hiding this comment

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

Second try to approve this …

@joa-quim
Copy link
Member

joa-quim commented Apr 5, 2020

Only that as a fix? But when

plon = gmt_M_memory (GMT, NULL, n, double);

it forgets about the memory that plon was pointing first in

double *plon = S->data[GMT_X]

@PaulWessel
Copy link
Member Author

Yes, but S is not going anywhere. I think it is OK. No more wrong frees, and no other effects across the tests.

@joa-quim
Copy link
Member

joa-quim commented Apr 5, 2020

But if S->data was not freed, and it's not going anywhere, it leeks.

@PaulWessel
Copy link
Member Author

Those are all taken care of by the garbage man later.

@PaulWessel
Copy link
Member Author

PaulWessel commented Apr 5, 2020

Remember, we have a full system checking if things are freed properly, so even though it did not crash for me, it told me that if was trying. Meaning, none of the memory allocated by gmt_M_memory can really leak without us knowing about it.

@joa-quim
Copy link
Member

joa-quim commented Apr 5, 2020

Later means at the end of the module. Why not free it right away? Clear to read and memory can be reused.

@PaulWessel
Copy link
Member Author

Not going to change the entire GMT memory management at this point. The file has all been read into memory, there is no urgency to free up space as relatively little else is allocated (e.g., plotting, and those gets deallocated)

@joa-quim
Copy link
Member

joa-quim commented Apr 5, 2020

OK, but it shouldn't even been doing this test at all. The seek polygon is in Cabo Verde. Far from any pole.

@PaulWessel
Copy link
Member Author

Well, no. It is doing this test since the user gave an oblique region and needs to know if any part of that overlaps with this polar cap . The answer was no, so we move on - except for the failure to change that bool variable. For straight w/e/s/n bounds we can determine that the segments w/e/s/n is outside the plot w/e/s/n. I can look to see if we do that here or deeper down. @KristofKoch could also use gmtselect to avoid plotting the entire world dataset for a small subregion.

@PaulWessel PaulWessel merged commit 69bc55d into master Apr 5, 2020
@PaulWessel PaulWessel deleted the memory-polefix branch April 5, 2020 22:52
@KristofKoch
Copy link
Contributor

@KristofKoch could also use gmtselect to avoid plotting the entire world dataset for a small subregion.

You are absolutely correct, @PaulWessel. Thank you for the hint towards select. I didn't think about that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants