godotengine / godotengine/godot-cpp

Assigning initialized String() or Array() as Dictionary values using the same key will slowly fill the memory

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

Description

To reproduce this bug I created a bare `MemFiller` class with a registered `_physics_process` and a class variable `Dictionary m_memory_filler`

This is the implementation of `_physics_process`
```
void MemFiller::_physics_process(float delta) {
m_memory_filler[1] = String("a");
m_memory_filler[2] = String("a");
m_memory_filler[3] = String("a");
m_memory_filler[4] = String("a");
m_memory_filler[5] = String("a");
m_memory_filler[6] = String("a");
m_memory_filler[7] = String("a");
m_memory_filler[8] = String("a");
m_memory_filler[9] = String("a");
m_memory_filler[0] = String("a");
}
```
Create a scene with a node with this native script attached and press play.

Even when doing absolutely nothing, memory usage will slowly grow overtime.
I saw the same behavior when assigning empty `Array()` objects. This does not happen if you assign `String()` instead of `String("wathever")`
I also tried with other three different versions of this, one with both `int` as key and value, one with `String` as key and `int` as value and one with both `String`.
The first two versions wich not used `String` as value worked as expected, while the other two filled the memory slowly.
I suppose that the initialized `String()` is not destroying cleanly. I tested this on the latest master.

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.