Out of memory: how to troubleshoot?
Posted: Sun Jun 14, 2020 9:05 pm
Recently I've been getting out-of-memory errors in my log shortly after loading my saved game, even if I stay docked and just let the clock run. I'm using Windows, with the developer build of 1.88 and with the debug console attached (N.B., the same errors appear in the Latest.log even if the debug console is not attached). In the console, the warnings look like this (unsurprisingly, this gets reported for all sorts of scripts, not just these particular ones):
Error: out of memory
Active script: Oolite Bounty Hunter AI 1.88
oolite-priorityai.js, line 279:
for (var i=activeHandlers.length-1; i >= 0 ; i--)
Error: out of memory
Active script: Oolite Police AI 1.88
oolite-priorityai.js, line 279:
for (var i=activeHandlers.length-1; i >= 0 ; i--)
.
.
.
etc.
How would you go about tracking down the root cause? I disabled a few OXPs and the OOM errors stopped happening. However, I'm not sure if my baseline memory usage is excessive. It's hovering just under 3 GB when I just let the game run (still docked, not doing anything). Here is a screenshot of the Resource Monitor showing the baseline: https://pasteboard.co/Jd5ZMJZ.png
I have extra logging enabled (I copied logcontrol.plist to my Oolite\Addons folder and flipped even more switches on). However, I don't see anything in the log that seems to implicate any particular OXP as a resource hog. Here is a "clean" Latest.log corresponding to the above Resource Monitor screenshot (with the game still idling in the background): https://pastebin.com/zNcgwRdv
Next, I re-enabled just one of the OXPs that I had disabled to get to the baseline stable level: phkb's new experimental PopulationControl.oxz. Here is the Latest.log with that OXP added: https://pastebin.com/SLQX9Kbg
I didn't manage to catch the Resource Monitor with a screenshot, but while my saved game was loading, I noticed that this time the memory usage briefly went above 3 GB before dropping back down. And, in the log, a single OOM error appeared around that time. After letting it idle and not seeing any further errors, I decided to try launching from the station to see if it would consume more memory. I did not see it tick over 3 GB [but I might have missed it], however a single additional OOM error did appear. As you can see in the log, there was one OOM before I launched, and one after. I auto-docked a few moments after that and then let it idle again, and the idling memory usage actually stabilized at a lower level than in the baseline run earlier (around 2.7 GB this run vs. around 2.9 GB before). One thing I see from comparing the logs is that the groupCount values total slightly lower (1 less?) for this second run than they did on the stable baseline run. However, with phkb's tweaked populator there was a larger groupCount for police and for hunters and a smaller groupCount for pirates.
For a third run, I restarted and loaded the same saved game, with no change in OXPs (still using phkb's tweaked populator). This time, I got a flood of OOM errors for several seconds until I paused the game. Again I missed the Resource Monitor screenshot, but it did spike to just above 3GB and stayed at that level while logging the errors. And, if I unpause it, the OOM errors continue. Here is the Latest.log for this run: https://pastebin.com/DLt9k883
In this unstable third run, the groupCount numbers for police and hunters were notably higher than in the stable run. Maybe a contributing factor.
(As a side note, I'm a bit confused by OOM errors happening at 3 GB, because I thought Oolite could use up to 4GB of memory?)
Where to go from here? I can reproduce this fairly easily, but it's not every time. I guess I'm close to the limit and random factors each time I load are deciding if I go over it. But I'm not sure why I'm so close to the limit. Any advice would be greatly appreciated. (I've made a separate thread instead of putting this in phkb's thread because I doubt that his OXP is directly responsible, I suspect it's just helping tip me over the edge.)
Thanks,
Milo
Error: out of memory
Active script: Oolite Bounty Hunter AI 1.88
oolite-priorityai.js, line 279:
for (var i=activeHandlers.length-1; i >= 0 ; i--)
Error: out of memory
Active script: Oolite Police AI 1.88
oolite-priorityai.js, line 279:
for (var i=activeHandlers.length-1; i >= 0 ; i--)
.
.
.
etc.
How would you go about tracking down the root cause? I disabled a few OXPs and the OOM errors stopped happening. However, I'm not sure if my baseline memory usage is excessive. It's hovering just under 3 GB when I just let the game run (still docked, not doing anything). Here is a screenshot of the Resource Monitor showing the baseline: https://pasteboard.co/Jd5ZMJZ.png
I have extra logging enabled (I copied logcontrol.plist to my Oolite\Addons folder and flipped even more switches on). However, I don't see anything in the log that seems to implicate any particular OXP as a resource hog. Here is a "clean" Latest.log corresponding to the above Resource Monitor screenshot (with the game still idling in the background): https://pastebin.com/zNcgwRdv
Next, I re-enabled just one of the OXPs that I had disabled to get to the baseline stable level: phkb's new experimental PopulationControl.oxz. Here is the Latest.log with that OXP added: https://pastebin.com/SLQX9Kbg
I didn't manage to catch the Resource Monitor with a screenshot, but while my saved game was loading, I noticed that this time the memory usage briefly went above 3 GB before dropping back down. And, in the log, a single OOM error appeared around that time. After letting it idle and not seeing any further errors, I decided to try launching from the station to see if it would consume more memory. I did not see it tick over 3 GB [but I might have missed it], however a single additional OOM error did appear. As you can see in the log, there was one OOM before I launched, and one after. I auto-docked a few moments after that and then let it idle again, and the idling memory usage actually stabilized at a lower level than in the baseline run earlier (around 2.7 GB this run vs. around 2.9 GB before). One thing I see from comparing the logs is that the groupCount values total slightly lower (1 less?) for this second run than they did on the stable baseline run. However, with phkb's tweaked populator there was a larger groupCount for police and for hunters and a smaller groupCount for pirates.
For a third run, I restarted and loaded the same saved game, with no change in OXPs (still using phkb's tweaked populator). This time, I got a flood of OOM errors for several seconds until I paused the game. Again I missed the Resource Monitor screenshot, but it did spike to just above 3GB and stayed at that level while logging the errors. And, if I unpause it, the OOM errors continue. Here is the Latest.log for this run: https://pastebin.com/DLt9k883
In this unstable third run, the groupCount numbers for police and hunters were notably higher than in the stable run. Maybe a contributing factor.
(As a side note, I'm a bit confused by OOM errors happening at 3 GB, because I thought Oolite could use up to 4GB of memory?)
Where to go from here? I can reproduce this fairly easily, but it's not every time. I guess I'm close to the limit and random factors each time I load are deciding if I go over it. But I'm not sure why I'm so close to the limit. Any advice would be greatly appreciated. (I've made a separate thread instead of putting this in phkb's thread because I doubt that his OXP is directly responsible, I suspect it's just helping tip me over the edge.)
Thanks,
Milo