Skip to content

Bug: all kind of array(Array, PoolByteArray, PoolStringArray ...) Memory leak when pass to GdNative #318

Closed

Description

@zhangshiqian1214

Godot version:
Godot 3.1.1.stable.official and Godot v3.1.2.devel.custom_build

OS/device including version:
Windows7

Issue description:
Only create a lot of array in GDscript, the memory can be freed.
Only create a lot of array in GDNative(cpp), the memory can be freed.
But create a lot of array and PoolByteArray, PoolStringArray and so on, the memory can not be freed. And If the memory used more than device, the project will memory leak and crash.

QQ截图20190805160317

For now I use something like this:

# test array
func _on_Button2_pressed():
	for i in range(10000):
		var data = []
		for j in range(1024):
			data.push_back(j)
		test.test_array(data)
	pass # Replace with function body.

The project I tested
gdnative_test.zip

Activity

  1. 2shady4u commented on Oct 15, 2019

    @2shady4u
    Contributor

    Heyo,

    I ran your test example project and could not replicate these memory leaks.
    This might've been fixed in a previous commit.

    Could you check if this problem still persists? @zhangshiqian1214

  2. zhangshiqian1214 commented on Oct 16, 2019

    @zhangshiqian1214
    Author

    @2shady4u OK, Today I clone new code, and this problem still persists.
    Godot version:
    Godot 3.1.1.stable.official and Godot v3.1.2.devel.custom_build and v3.2.alpha.custom_build.a1033aea5

    OS/device including version:
    Windows7

    godot-cpp:
    master

    How to repeat:
    click the button "test array" some times. And you can see the memory rise and will not release.
    You can click until you computer memory use up. And the same code in gdscript and no gdnative,
    the memory will not rise.
    I have try to debug in vs2017, but i just find array ref() is more than unref(). But i don't know how to fix this problem.

    1
    2
    3

  3. zhangshiqian1214 commented on Dec 4, 2019

    @zhangshiqian1214
    Author

    I use #355 code and test ok, memory will not leak

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions