texture memory keep increasing when call graphics.newOutline

_T = display.screenOriginY

_CX = display.contentCenterX

local function  getMemoryUsage()

        local memUsed = (collectgarbage(“count”))

        local texUsed = system.getInfo( “textureMemoryUsed” ) / 1048576 – Reported in Bytes

        return “system:” … string.format("%.00f", memUsed) … “KB” … " texture:"…  string.format("%.03f", texUsed) … “MB”

end

local memoryUsageText

local function monitorMem()

local memUsed = (collectgarbage(“count”))

local texUsed = system.getInfo( “textureMemoryUsed” ) / 1048576 – Reported in Bytes

    memoryUsageText.text = string.format("%.00f", memUsed) … “KB” … " texture:"…  string.format("%.03f", texUsed) … “MB”

end

if memoryUsageText == nil then

    memoryUsageText = display.newText(getMemoryUsage(), _CX - 50, _T + 20, native.systemoFont, 64 )

    memoryUsageText.alpha = .5

    --memoryUsageText:setFillColor( uHexColor("#ff0000aa"))

    Runtime:addEventListener( “enterFrame”, monitorMem )

end

local cnt = 1

local function myListener()

local baseDir = system.DocumentsDirectory

local capture = display.captureScreen()

display.save( capture, cnt … “.png”, baseDir )

local imageOutline = graphics.newOutline( 2,  cnt … “.png”, baseDir )

capture:removeSelf()

cnt = cnt + 1

end

Runtime:addEventListener( “touch”, myListener )

When touching the screen, texture memory will keep increasing.

You never remove imageOutline.

Rob

The ImageOutline is a table of x and y coordinates, It’s not the reason cause this question.

You should have a try the code, and you will know what the problem is.

Hi @pickerel,

My initial suspicion is that you’re severely overloading the system. You don’t use any touch “phase” detection at all, so theoretically you’re generating dozens or even hundreds of screen captures in a single motion, then you’re trying to save each one to a file, then you’re trying to read that file into an outline, then finally discard the capture. Honestly, I’m surprised it doesn’t crash the device immediately. I suggest that you do some basic defensive coding for this.

Best regards,

Brent

If you comment this line: 

local imageOutline = graphics.newOutline( 2,  cnt … “.png”, baseDir )

The texture memory will not increase. 

The screen capture is just for generate different images, you can skip this step if you present images youself. This code is just for simplify the question.

Test the code, and you will understand what I say.

First of all, texture memory is not increasing. Lua system memory is.  This is the table being created by graphics.newOutline.  But it does appear the API call is holding on to a little bit of system memory.

Can you file a bug report?

Rob

Hi Rob,

On my pc, texture memory is keeping increase. I don’t care about system memory, because it’s a little bit.

texture memory:

tap 0: 0.052MB

tap 1: 6.062MB

tap 2: 12.055MB

tap 3: 18.055MB

tap 17: 105.058

my system is mac os, and sdk version Version 2015.2565.

I will report a bug now.

Hi Rob,

How can i track status of the bug my reported?

When it gets worked on, you will get an email from Support.  I can always look up a bug report number for you.  Since this bug was just reported a few days ago its probably still in the incoming queue pending validation and assignment.

Rob

You never remove imageOutline.

Rob

The ImageOutline is a table of x and y coordinates, It’s not the reason cause this question.

You should have a try the code, and you will know what the problem is.

Hi @pickerel,

My initial suspicion is that you’re severely overloading the system. You don’t use any touch “phase” detection at all, so theoretically you’re generating dozens or even hundreds of screen captures in a single motion, then you’re trying to save each one to a file, then you’re trying to read that file into an outline, then finally discard the capture. Honestly, I’m surprised it doesn’t crash the device immediately. I suggest that you do some basic defensive coding for this.

Best regards,

Brent

If you comment this line: 

local imageOutline = graphics.newOutline( 2,  cnt … “.png”, baseDir )

The texture memory will not increase. 

The screen capture is just for generate different images, you can skip this step if you present images youself. This code is just for simplify the question.

Test the code, and you will understand what I say.

First of all, texture memory is not increasing. Lua system memory is.  This is the table being created by graphics.newOutline.  But it does appear the API call is holding on to a little bit of system memory.

Can you file a bug report?

Rob

Hi Rob,

On my pc, texture memory is keeping increase. I don’t care about system memory, because it’s a little bit.

texture memory:

tap 0: 0.052MB

tap 1: 6.062MB

tap 2: 12.055MB

tap 3: 18.055MB

tap 17: 105.058

my system is mac os, and sdk version Version 2015.2565.

I will report a bug now.

Hi Rob,

How can i track status of the bug my reported?

When it gets worked on, you will get an email from Support.  I can always look up a bug report number for you.  Since this bug was just reported a few days ago its probably still in the incoming queue pending validation and assignment.

Rob