Over the course of two days, it begins to use 25% of the memory.
Can someone who is good with script have a look for me, please?
P.S. The script isn't that long; if I knew what I was looking for, I imagine it's probably obvious

Code: Select all
if (feof(STDIN))
break;
I'm not quite sure where (I'm still no good with it).Light wrote:Do you have anything killing the script? If it gets stuck in the while loop, they tend to just stack on top of each other.
That may solve your issue if you put it inside of your while loop.Code: Select all
if (feof(STDIN)) break;
Code: Select all
while (!feof(STDIN)) {
$line = rtrim(fgets(STDIN, 1024));
$split = explode(" ", $line);
Code: Select all
while (!feof(STDIN))
break; {
$line = rtrim(fgets(STDIN, 1024));
$split = explode(" ", $line);
Code: Select all
ps aux
Code: Select all
ps aux | grep 'script\.php'
You can. I used to pipe to PHP scripts, and now I use the built-in script spawn / kill. Both exit the loop when the game server restarts. When I was doing it myself, I know without checking for EOF I would get scripts spawning on top of each other. I've never tried the built-in commands without checking EOF. The server may kill the script itself, but my scripts still have the EOF check in them, and don't spawn on top of each other.Lucifer wrote:How does it run? Is it running on a webserver? Or is it being executed from the arma dedicated server? Running as a separate process?
I don't think that in PHP you can get an EOF for STDIN, which is why I ask, of course. In fact, I'm not sure you ever get an EOF for STDIN (it works with cat because you press ctrl-d, which is an EOF).
I believe they're starting it in the start script alongside the server - they aren't using SPAWN_SCRIPT for some reason.Lucifer wrote:How does it run? Is it running on a webserver? Or is it being executed from the arma dedicated server? Running as a separate process?
If that's the case, then I'm going to suggest changing the setup so that the script gets restarted. Do something similar to the way you can have the dedicated server quit automatically when there are no players for a period of time (I forget the setting for this, but it's been there a long time), then the initscript restarts the server.aP|Nelg wrote:I believe they're starting it in the start script alongside the server - they aren't using SPAWN_SCRIPT for some reason.Lucifer wrote:How does it run? Is it running on a webserver? Or is it being executed from the arma dedicated server? Running as a separate process?
DEDICATED_IDLE is the setting you're talking about. The script running the server would just have to manage looping the execution of the server. You can forcefully kill the script each time as well if the problem is that, but there's something else wrong with the setup or script if that's happening.Lucifer wrote:If that's the case, then I'm going to suggest changing the setup so that the script gets restarted. Do something similar to the way you can have the dedicated server quit automatically when there are no players for a period of time (I forget the setting for this, but it's been there a long time), then the initscript restarts the server.
If that is the case, you could also free the memory by unsetting the vars or setting them to null (close enough). I do realize that's a little more work than just killing the script though.Lucifer wrote:In short, I'm saying you could be doing it perfectly right and the interpretor is what's screwing you over, so don't let the script run for too long. If it's fine for a day, restart it once a day, problem solved.
Also, explicitly creating the variables before the loop even starts will stop the leak, if that's the case. The leak is caused by the part where the local variables inside the loop don't get garbage-collected until the loop is exited, but new variables get spawned. I've tested this thoroughly with Python, at least, and read about it in php, java, and perl (ruby doesn't have this problem, according to dlh). I've made it a habit of creating all loop variables before entering the loop, and that's fixed 90% of my memory leaks in scripts.Light wrote:If that is the case, you could also free the memory by unsetting the vars or setting them to null (close enough). I do realize that's a little more work than just killing the script though.Lucifer wrote:In short, I'm saying you could be doing it perfectly right and the interpretor is what's screwing you over, so don't let the script run for too long. If it's fine for a day, restart it once a day, problem solved.
I generally agree, but the difference between you and I is that you've actually seen his script.With how long SPAWN/KILL_SCRIPT has been available, I don't see the reasoning for running the script separately. I can't imagine you gain anything useful from doing so.
Sort of. I haven't exactly sat down and looked at it. I glanced quick enough to see that EOF was checked.Lucifer wrote:I generally agree, but the difference between you and I is that you've actually seen his script.
Well, if he'd posted it here in a code block, I'd have read it in some detail and offered more useful feedback.Light wrote:Sort of. I haven't exactly sat down and looked at it. I glanced quick enough to see that EOF was checked.Lucifer wrote:I generally agree, but the difference between you and I is that you've actually seen his script.