How to unload texture?(SOLVED)

I need to create a new texture every frame. What happens with previous textures? Looks like they don’t unload, because dmengine use more and more memory.

local header = {width = SCREEN.WIDTH, height = SCREEN.HEIGHT, type = resource.TEXTURE_TYPE_2D, format = resource.TEXTURE_FORMAT_RGB, num_mip_maps = 0}
resource.set_texture(self.resource_path, header, SCREEN.BUFFER)
1 Like

Isn’t it garbage collecting after a while?

No, dmengine use 10gb memory.I have 12 gb. But dmengine can’t get more and freeze.

And what happens when you’re closing in on the mem cap of your desktop/laptop? Does it crash with oom or does it gc?

It can’t get more and freeze. Also my pc is freezing too, look like it try to free memory. Then if enought free memory, dmengine create one more texture

I can share project, if it help.

Yes, please share it with me (Bjorn.ritzl@king.com). I can take a look at it beginning of next week.

1 Like

Solved in 1.2.120

7 Likes

Same happened again=)

M.WIDTH = 960/2
M.HEIGHT = 540/2
M.BUFFER = buffer.create(M.WIDTH * M.HEIGHT, { {name=hash("rgb"), type=buffer.VALUE_TYPE_UINT8, count=3} } )

function M.update_texture(resource_path)
	local header = {width = M.WIDTH, height =M.HEIGHT, type = resource.TEXTURE_TYPE_2D, format = resource.TEXTURE_FORMAT_RGB, num_mip_maps = 0}
        --comment next line no memory leak
	resource.set_texture(resource_path, header, M.BUFFER)
end

1 Like

@britzl I add you to project.(Shooter). Please look at when you have time=)

Ok, so how do I reproduce it?

1 Like

1)Open project
2)Press 9 (it wil show memory usage in right top corner)
3)Memory usage will be increased, every frame

In native_render/helper.lua you can comment resource.set_texture

Memory usage isn’t increasing for me on OSX. You’re on Windows right?

1 Like

Yes

Hmm, and you’re actually running out of memory eventually? It’s not just a number that is growing but has no real meaning?

Yes. I can play 3-4 minutes, then dmengine use 11gb of memory, and all freezed=)

Also i am not sure. But i think that on desktop i don’t have memory leak, it also windows. Now i use laptop. But i can’t check now.

No memory leak on pc.
I use same defold version in pc and laptop. Windows7. Very strange :exploding_head:
My laptop: lenovo e440.