Maintain file open - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Maintain file open (
/showthread.php?tid=601134)
Maintain file open -
Yvax - 17.02.2016
Hello!
Is it a good practice to keep log files open throughout the uptime of the server instead of fopen & fclose everytime you log something?
E.g
Код:
-fopen
-fwrite
-fclose
REPEAT EVERYTIME
vs
GLOBAL var file + fopen
REPEAT fwrite
ON SHUTDOWN fclose
I usually keep files open, but it seems that pawn people don't do this.Is there a reason or what?It's obv. faster to open once.
LE:I don't see any issue memory wise as there's only about 20 not that large files to keep open.
Re: Maintain file open -
BiosMarcel - 17.02.2016
that actually an interessting question, especially for me , i made a log filterscript where a lot of things are logged, probably i should srsly open the files only once in some cases, it may save performance but not memory ^^
Re: Maintain file open -
Yvax - 17.02.2016
I just tested and the fastest way is to open files, fwrite, and then fclose + fopen every hour, so that you can still acces logs in relatively real time.Anybody know some downsides of this?I mean, it's much faster like this than opening and closing every log line.
Re: Maintain file open -
BiosMarcel - 17.02.2016
like i said, one of the downsides would be the memory usage
Re: Maintain file open -
Gammix - 17.02.2016
Yes its good to have them open if they are frequently used or often.
Don't worry about RAM usage, it would be negligible.
Re: Maintain file open -
Yvax - 18.02.2016
Quote:
Originally Posted by [Bios]Marcel
like i said, one of the downsides would be the memory usage
|
Besides that, obviously.