godotengine / godotengine/godot-cpp

Pool*Arrays leaks

Open
#223 7 comments 1 reaction 0 assignees View on GitHub
bug needs testing
Dominant language
C++
Stars
2.7k
Forks
809
Avg merge
1d 3h
Merged PRs (30d)
8

Description

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:
```c++
void GDNObj::set_data(const PoolByteArray p_data) {

if (p_data.size() == 0)
return;

if (data)
std::free(data);

data = std::malloc(p_data.size());
std::memcpy(data, p_data.read().ptr(), p_data.size());
}
```

gdscript code:
```gdscript
func _ready():
var gdn_obj = GDNObj.new()
var bytes = PoolByteArray([0x41, 0x00, ... , 0x74, 0x00])
gdb_obj.set_data(bytes)
```

Results in following error message at exit:
```
ERROR: cleanup: There are still MemoryPool allocs in use at exit!
At: core/dvector.cpp:70.
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.