Maintain file open
#1

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.
Reply
#2

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 ^^
Reply
#3

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.
Reply
#4

like i said, one of the downsides would be the memory usage
Reply
#5

Yes its good to have them open if they are frequently used or often.

Don't worry about RAM usage, it would be negligible.
Reply
#6

Quote:
Originally Posted by [Bios]Marcel
Посмотреть сообщение
like i said, one of the downsides would be the memory usage
Besides that, obviously.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)