Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

newTableView memory management.
Started by ammar71 Oct 28 2019 12:16 PM

No replies to this topic
widget newtableview
[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

ammar71

[GLOBAL: userInfoPane.html]
ammar71
  • Enthusiast

  • 60 posts
  • Corona SDK

Hi all,

 

I am experimenting with the widget.newTableView.

https://docs.coronalabs.com/api/library/widget/newTableView.html

 

I noticed that in the example, in the onRenderEvent we have:

local rowTitle = display.newText( row, "Row " .. row.index, 0, 0, nil, 14 )

Every time we scroll up or down, newText is created on the fly. There is no code to delete the ones that scroll off the view. Is that a good idea or could that lead to a memory leak?

 

Also, I am trying to highlight (change the colour) of a row when it is touched. For that I would need a reference to the newText object. I can keep references to those in a table as follows:

local rows = {}

Then in the RenderEvent:

rows[event.row.index] = display.newText( row, "Row " .. row.index, 0, 0, nil, 14

But again, every time a row is rendered, a newText object is created and the reference to the old one is lost.

Should I check the value of rows[event.row.index] before assigning the new newText and try to remove the old refernce with display.remove(rows[event.row.index]) or is that not needed?

 

Many thanks.

 




[topic_controls]
[/topic_controls]

Also tagged with one or more of these keywords: widget, newtableview