PtokaX forum

Archive => Archived 5.0 boards => Help with scripts => Topic started by: TTB on 27 May, 2005, 19:46:36

Title: Flush() and CollectGarbage()
Post by: TTB on 27 May, 2005, 19:46:36
Hi,

I have a problem. My script is taking to much memory, and I think it is because I don't use Flush() and CollectGarbage(). So here is also my question: What does it really do, and when is it useful?

My script is taking 300 Mb memory after 3 days running (not g00d).

Some help would be appriciated (links to info sites also).
Title:
Post by: Pothead on 27 May, 2005, 20:08:05
Flush writes stuff it got in memory to files.  Should use this often.
CollectGarabage free's all the memory which isn't needed anymore.  This should also be used quite often. :)
Title:
Post by: TTB on 27 May, 2005, 20:13:49
QuoteOriginally posted by Pothead
Flush writes stuff it got in memory to files.  Should use this often.
CollectGarabage free's all the memory which isn't needed anymore.  This should also be used quite often. :)

"Flush writes stuff it got in memory to files." I don't get this. So flush writes data in files? Maybe someone can give an example, I don't get it very well...

The CollectGarbage() should I use after deleting data from the temp tables? And can it erase data what is still needed?
Title:
Post by: ??????Hawk?????? on 27 May, 2005, 21:34:20
function Clear()
collectgarbage();io.flush();
end

i call this every 5 mins  ...   Maby a bit of an over kill  But  works :P  :P
Title:
Post by: TTB on 28 May, 2005, 03:18:59
Hi, I will try that. I hope it will work with my huge script... Thanx  :D
Title:
Post by: Pothead on 28 May, 2005, 12:19:43
QuoteOriginally posted by TTB
"Flush writes stuff it got in memory to files." I don't get this. So flush writes data in files? Maybe someone can give an example, I don't get it very well...
It saves some information in memory which will be written to files when the script stops / ptokaX closes.  Flush forces it to dump this information into the files, and outta the memory.