PtokaX forum

Development Section => Your Developing Problems => Topic started by: Neo on 12 November, 2003, 17:16:34

Title: Release memory used by array (or table)
Post by: Neo on 12 November, 2003, 17:16:34
Hi guys...
I've a little little problem:
I use in my userinfo scripts some tables. Now:
Start hub-->memory=256K
Running-->memory=6000-8000 Kb

During run i don't need all of theese tables and i want to discard them...but HOW?? ?(  ?(  ?(

I've tried to re-initialize them (tablename={}) but memory is not released...

Please help me...

Thanks in advance!!

Bye!
Title:
Post by: pHaTTy on 12 November, 2003, 17:20:31
pretty much a guess but have you tried to give it a nil input, works with some other laguages

tablename={nil}
Title:
Post by: Optimus on 12 November, 2003, 17:22:37
well maybe this helps abit, duno for sure if it's what you looking for...

Code:

function Clear()
   collectgarbage()
   flush()
end
Title:
Post by: pHaTTy on 12 November, 2003, 17:23:36
thats what i use for my function OnExit()
Title:
Post by: NightLitch on 12 November, 2003, 18:07:36
So How would a correct function look like then if I want
to emty the table...

I have same table in every userfile

so when loading one and then another one above first should be overwritten right???

Or is it a way to clear the data in memory when usercommand is used???

This was a nice thread... Got me open my eyes... hehe...

/NightLitch
Title:
Post by: c h i l l a on 12 November, 2003, 18:10:52
i thaught table = {}  is enough, and the garbage collector will do the rest by time ? or not?
Title:
Post by: Optimus on 12 November, 2003, 18:20:34
but if C: & T: are getting high then this is a nice trick to refresh them without restarting script or loosing any data... If i'm explaining this correctly. Think it can be done in some more words

So there for i say it helps -->> A Bit <<---

But maybe there are some more tricks... really like to know them then?
Title:
Post by: pHaTTy on 12 November, 2003, 18:24:03
hmmmmm well in that case


you cud add this function to the bot


function Clear()
anytableyuwannaclear = {}
andvaribaletoclear = nil
collectgarbage()
flush()
end


then ontimer or whereer add


function OnTimer()
Clear()
end


thats how my flush works
Title:
Post by: Neo on 12 November, 2003, 18:29:22
QuoteOriginally posted by c h i l l a
i thaught table = {}  is enough, and the garbage collector will do the rest by time ? or not?

YESSS!!
I've used first only Clear()...and nothing...
then i've used table={} and Clear() and it's OK!!
THANKS TO ALL!!! :D