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

Inability to free what GMT_Encode_Options return #18

Open
PaulWessel opened this issue Apr 7, 2021 · 1 comment
Open

Inability to free what GMT_Encode_Options return #18

PaulWessel opened this issue Apr 7, 2021 · 1 comment
Assignees

Comments

@PaulWessel
Copy link
Member

Description of the problem

Since I am building GMT with DEBUG and MEM_DEBUG I get messages upon module exit if there were memory leaks. WHen I quit MATLAB after testing gmtmex I may get many of these, probably one for each module call:

Matlab [WARNING]: Memory not freed first allocated in gmt_api.c:12781(GMT_Encode_Options) (ID = 141): 0.141 kb [144 bytes]

The problem is that gmtmex.c does not bother to free the info structure array returned by GMT_Encode_Options. OK, so two issues:

  1. That array is allocated with GMT_memory and thus is tracked by GMT's garbage man
  2. The API has no way of calling GMT_free since all it has is GMT_Destroy_Data which would not work on some random array.

I think the solution is:

  1. Let GMT_Encode_Options allocate directly with malloc/realloc and not GMT_memory
  2. Let gmtmex.c clean up after itself.

OK with you @joa-quim ?

@PaulWessel PaulWessel self-assigned this Apr 7, 2021
@joa-quim
Copy link
Member

joa-quim commented Apr 8, 2021

I geuss yes. I probably have the same issue in Julia.

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

No branches or pull requests

2 participants