modern-fortran / neural-fortran

A parallel framework for deep learning
MIT License
398 stars 82 forks source link

fixed a memory leak when reading the JSON #83

Closed jacobwilliams closed 2 years ago

jacobwilliams commented 2 years ago

Fixes #82

milancurcic commented 2 years ago

Thanks!

And just so I'm sure I understand: The reason we don't need to destroy other json_value pointers, in this case, is because they are all pointing to child nodes of model_config_json, so by destroying it, we free the whole structure including the child nodes, yes?

jacobwilliams commented 2 years ago

Yep, that is correct. The destroy call deallocates the entire tree structure.

The other variables are pointers to the existing structure. When you destroy the structure they are now dangling pointers, but since they are just local variables it doesn't matter.