Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]

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

No replies to this topic
widget newtableview
[TOPIC: post.html]


[GLOBAL: userInfoPane.html]
  • Enthusiast

  • 60 posts
  • Corona SDK

Hi all,


I am experimenting with the widget.newTableView.



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.



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