You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jun 14, 2022. It is now read-only.
LucasMZ edited this page Sep 3, 2021
·
2 revisions
There are cases on which you should, or should not recycle an object, and when you should.
Managing such things the wrong way can be problematic to memory usage, recycling is not always the solution.
Recycling objects can sometimes mean not letting them be garbage collected right away / stopping them from being so, so you need to think about weather you should recycle such objects or not.
Properly re-using objects with high amounts of memory allocated to such
Take for instance, that you're recycling a simple table, that table is an array, and you inserted 1000 objects onto it.
Even after that table is cleared, the memory that was allocated in order to insert those 1000 objects inside of it, is still being used.
That memory only gets freed up once that table gets garbage collected.
With that said, if you're be re-using these tables, be sure you're only reusing them for things that ALSO would to allocate amounts of memory like these,
if you're reusing a table that has large amounts of memory allocated to it, to only store some values, then you have a memory problem on your hands.
Therefore, if you're gonna be recycling big tables, don't reuse them for small things, only reuse them for other usage on which you would be allocating a lot of memory for them as well.