Memory Leak with webPopups?

As I have been testing my app and looking at memory stats in Instruments, I saw that when I call a webPopup, my memory usage shoots up about 10MB, but only falls about 2-5MB when it is closed. Is the new web view any better in terms of memory usage? (I assume it is webPopup, not my code, right?) How can I deal with this?
Here is my code (I use the webPopup to open Twitter):
[lua] local TwitterButtonRelease = function(event)
local function escape (s)
s = string.gsub(s, “([&=+%c])”, function ©
return string.format("%%%02X", string.byte©)
end)
s = string.gsub(s, " ", “+”)
return s
end

tweetText = “This is a test tweet from my app!”
local postBody = escape( tweetText )
local theNetwork = theNetwork or “twitter”

if theNetwork == theNetwork or “twitter” then
if highscoreText then
highscoreText.isVisible = false
end

native.showWebPopup(0, 35 + display.screenOriginY, 480, display.contentHeight + 35 + display.screenOriginY, “http://twitter.com/intent/tweet?text=”…postBody)
end
local rectangle = display.newRect(0, 0, 480, 50)
rectangle:setFillColor(0, 0, 0)
local closeButton = ui.newButton{
default = “Images/backButton.png”,
over = “Images/backButtonOver.png”,
–text = “I’m done, close the window!”,
–font = “Trebuchet MS”,
–textColor = { 0, 0, 0, 255 },
–size = 26,
–emboss = true,
}
closeButton.y = 16 + display.screenOriginY
closeButton.x = 40

local closeWindow = function(event)
native.cancelWebPopup()
display.remove(closeButton)
display.remove(rectangle)
if highscoreText then
highscoreText.isVisible = true
end
return true
end
closeButton:addEventListener(“tap”, closeWindow)

return true
end[/lua] [import]uid: 38000 topic_id: 20893 reply_id: 320893[/import]

What build? There was a webpopup memory leak fix for iOS/Mac that went in right after the stable release.

The new webview should clean up well assuming you completely remove/destory the display object and garbage collection kicks in.
[import]uid: 7563 topic_id: 20893 reply_id: 82369[/import]

@eric - do you know which build exactly is the one that you mentioned above that fixes the memory leak (close after the last stable release)?

PS: Sorry @Peter to “hijack” your post but I just wanted to get @ewing`s word about it too.

Cheers,
Thanks.
Rodrigo. [import]uid: 89165 topic_id: 20893 reply_id: 82374[/import]

I think it was build 707. [import]uid: 7563 topic_id: 20893 reply_id: 82376[/import]

Bad…am using the 706 because it was the last one that does support old iOS (before 4.3). :\

By the way, thank you @Eric.
Cheers,
Rodrigo.
[import]uid: 89165 topic_id: 20893 reply_id: 82379[/import]

I am using build 726.
[import]uid: 38000 topic_id: 20893 reply_id: 82386[/import]

Hmmm… I encourage you to try the new web view and see if it is any better. Moving forward, we want to eventually deprecate webpopup anyway.
[import]uid: 7563 topic_id: 20893 reply_id: 82394[/import]

Hi guys, I’m using daily build 706, and when I do the following, I don’t see memory leak:

[lua]-- this is how I use show webpopup
local function showWeb()
local url = “http://www.google.com
native.showWebPopup( 0,0, screenW, screenH-60, url)
end

–this is how I cancel webpopup
local function closeWeb()
native.cancelWebPopup()
end[/lua]

I have a button that triggers the showWeb, and another button that calls closeWeb. Tapping on show / close repeatedly does not increase the memory for me.

So… I have to assume daily build 706 has the fix already in… Please let me know if this isn’t the right way to test this issue.

Naomi

Edit: I edited the code to show how webpopup doesn’t cover up the screen. I have two buttons at the bottom where it’s easily accessible. [import]uid: 67217 topic_id: 20893 reply_id: 82617[/import]

If I recall, I don’t think it was a memory leak in the classic sense. The problem was Apple was aggressively caching things with the WebView. Somebody was loading many megabytes of images in the WebView. When we closed the web view, we closed the display, but held onto the renderer backend. Apple’s caching in some cases would not free this memory or not free it immediately. The new code releases the renderer backend too hoping it will force the cached memory to be freed immediately.
[import]uid: 7563 topic_id: 20893 reply_id: 82621[/import]

@Eric, I really appreciate this input from you. It does make me less “neurotic” about memory leaks. (lol)
[import]uid: 89165 topic_id: 20893 reply_id: 82627[/import]

Hi, Eric, thank you for the explanation. Whew, I feel the same way as Rodrigo. My game hardly uses webPopUp – maybe a user may come across it after a while, if ever. So for me, it sounds like a non issue.

Thanks again.

Naomi [import]uid: 67217 topic_id: 20893 reply_id: 82628[/import]

That didn’t seem to help. In fact, after going up 8MB after webView was called, it only went down 0.5MB when it was closed. [import]uid: 38000 topic_id: 20893 reply_id: 83014[/import]