Open bruvzg opened 5 years ago
Confirmed in commit 7cbb846. Any PoolArray, even if it's not accessed, will leak as soon as a change is made on any of the PAs (GDS side or GDN side).
Still failing in commit 9eceb16 , but only changes made on the GDScript side trigger the leak.
@Ovnuniarchos Do you have a full example code that includes "changes made on the GDScript side"?
I was encountering the AFAICT original issue which appears to be gone in https://github.com/godotengine/godot-cpp/commit/9eceb16f0553884094d0f659461649be5d333866 (although I didn't try @bruvzg's specific example) so I wondered what was different with what you were observing and if I understood what you meant by "changes made on the GDScript side".
Related to what I'm trying to summarize here: https://github.com/godotengine/godot-cpp/issues/417
@follower I'm still having this issue on the latest master for my SQLite plugin: https://github.com/2shady4u/godot-sqlite/tree/feature-add-blobs
So I don't think it's fixed yet? 🤔
I tried reproducing it on Windows but was unable to do so. I used a library compiled in debug mode.
I tested in Godot 3.2.3 stable and some version of Godot 3.2.4 dated from december 2020. Using -v
for verbose output, nothing showed up.
All my code is doing is this:
func test_pool_byte_array(): # Called from _ready
print("BEGIN test_pool_byte_array")
var test = CustomReference.new()
var data = PoolByteArray([1, 2, 3])
test.test_pool_byte_array(data)
# data[0] = 42 # Also tried this, no problem
print("END test_pool_byte_array")
C++:
void CustomReference::test_pool_byte_array(godot::PoolByteArray data) {
PoolByteArray::Read r = data.read();
}
To properly figure this out, we need an actual minimal reproduction project (MRP), because it's still not clear under which circumstances this problem occurs (if it still occurs).
FYI there was a PR back in december 2019 which fixed a leak in PoolArrays: https://github.com/godotengine/godot-cpp/pull/355
Update: we found various cases of leaks when some methods of Dictionary
and Array
are used, like values()
or duplicate()
. The leak then becomes apparent when they contain either poolarrays or resources (and curiously doesn't otherwise). However, we could not find an issue with PoolArrays yet.
Seems like my example is faulty as it pertains to having a PoolArray or Resource in an Array
and then duplicating it (or Dictionary
and values()
), as mentioned by @Zylann in the post above
Pool arrays created in gdscript and passed to gdnative module are leaking. Or am I missing something and pool arrays should be freed manually?
gdnative module code:
gdscript code:
Results in following error message at exit: