Memory leak in version 1.70

For test results, bug reports, announcements of new builds etc.

Moderators: winston, another_commander, Getafix

Sardar
Average
Average
Posts: 9
Joined: Tue Dec 11, 2007 5:49 pm

Memory leak in version 1.70

Post by Sardar »

Yesterday I've tried the latest development version.
Sometimes when you enter the hyperspace (key h), the game freezes and begins allocating memory in large chunks. Within 20 seconds up to 1.5Gb of used memory is shown in process monitor(system's total), while the usage of oolite.exe remains at 70Mb. There are no other processes running (except notepad with notes), so I guess nobody but oolite eats up the memory.

That happens once in 5-7 jumps. Restarting the game ensures the next jump will not crash.

System: HP Pavilion dv5000 series notebook (Core Duo)
Windows XP Home (SP2)
Intel 945GMA (shaders disabled, no support)
1Gb RAM
2.5Gb of free space on HDD
User avatar
JensAyton
Grand Admiral Emeritus
Grand Admiral Emeritus
Posts: 6657
Joined: Sat Apr 02, 2005 2:43 pm
Location: Sweden
Contact:

Re: Memory leak in version 1.70

Post by JensAyton »

I’ve had a number of reports of leaks and similar, but not been able to reproduce them. Instrumentation has shown almost no leaks, although I haven’t tested very extensively. This is definitely something that needs more work.

If the situation is not recoverable, it could be that a script or AI is stuck in infinite recursion. I’ve found and trapped some of these situations, but probably not all of them. Do you have many OXPs installed?

As far as I can tell, the 945GMA is a motherboard chipset with an integrated GMA 950 graphics core. This is capable of handling simple shaders, faster than my current system (I’ve tested with it in a MacBook). You may need newer drivers.
Sardar
Average
Average
Posts: 9
Joined: Tue Dec 11, 2007 5:49 pm

Re: Memory leak in version 1.70

Post by Sardar »

Ahruman wrote:
but not been able to reproduce them
Same problem on Athlon XP, GeForce 6800GT, WinXP Home SP2, 512Mb RAM. I've played for 2 hours now, the game has crashed only once, this is acceptable =)

Ahruman wrote:
If the situation is not recoverable, it could be that a script or AI is stuck in infinite recursion. I’ve found and trapped some of these situations, but probably not all of them. Do you have many OXPs installed?
No, clean game. The scripting engine should have some kind of garbage collector, so no matter how long it runs (in infinite loop), the memory should not be eaten at this rate...
Ahruman wrote:
As far as I can tell, the 945GMA is a motherboard chipset with an integrated GMA 950 graphics core. This is capable of handling simple shaders, faster than my current system (I’ve tested with it in a MacBook). You may need newer drivers.
Probably software emulation, as in Linux/Mesa... Anyway, I will try the latest driver directly from Intel (HP/WinXP have no updates for year), thanks for the tip.
Sardar
Average
Average
Posts: 9
Joined: Tue Dec 11, 2007 5:49 pm

Re: Memory leak in version 1.70

Post by Sardar »

No, with the latest drivers for WinXP home I can't get shader's on.
Funny thing, Intel proposes this chip for Vista (that "capable" buzzword). I'm not sure the customers will be happy with such config...

While testing I've got that freeze again while selecting saved game profile. Same symptoms, eats memory in 20-40Mb per second.

There is another bug with scripts. I've 8k of credits, trying to buy military laser (price: 6k). Once the laser is installed, I get 4M of credits! =)
If i try to buy everything (tech level 12), then this amount jumps in randomly fashion until I get < 100. Anyway it is possible to buy things for more than 8k.
Reproducibility: always. This has killed the game/fun =/


I will try 1.68 version from now on.
User avatar
JensAyton
Grand Admiral Emeritus
Grand Admiral Emeritus
Posts: 6657
Joined: Sat Apr 02, 2005 2:43 pm
Location: Sweden
Contact:

Re: Memory leak in version 1.70

Post by JensAyton »

Sardar wrote:
The scripting engine should have some kind of garbage collector, so no matter how long it runs (in infinite loop), the memory should not be eaten at this rate...
Your assumption is incorrect. Explaining how it is incorrect would require some exposition on the details of the legacy scripting engine and OpenStep memory management, but in short, memory is reclaimed after scripts are run, not during the running, which is OK because they can’t loop or recurse – except through bugs in the game. Besides, I said infinite recursion, not an infinite loop; this leads to a form of stack explosion.
Sardar wrote:
Probably software emulation, as in Linux/Mesa...
This assumption is also incorrect. The GMA 950 is capable of running simple GLSL fragment shaders (but not vertex shaders) in hardware. I know this because a) documentation tells me so and b) the tools I were using tell me whether a shader is running in hardware or in software fallback mode.
Sardar wrote:
There is another bug with scripts. I've 8k of credits, trying to buy military laser (price: 6k). Once the laser is installed, I get 4M of credits! =)
You get a rebate for the equipment that’s being replaced.
Sardar
Average
Average
Posts: 9
Joined: Tue Dec 11, 2007 5:49 pm

Re: Memory leak in version 1.70

Post by Sardar »

Ahruman wrote:
but in short, memory is reclaimed after scripts are run, not during the running, which is OK because they can’t loop or recurse – except through bugs in the game.
Probably that makes debugging a lot harder... Anyway, I think there should be a limit on memory to use, allocating and deallocating in large chunks, like Apache webserver does.
Ahruman wrote:
Besides, I said infinite recursion, not an infinite loop; this leads to a form of stack explosion.
It is probably to late to change anything, but I think that scripting engine should be replaced by something more optimized. At least tail-recursion optimization is needed if recursion is extensively used. Non strict functions (like those in Haskell or other func. lang-s. implies lazy eval.) will be a great feature to define endless sequences (of actions) and will bring recursion to a "new level" =)
Ahruman wrote:
The GMA 950 is capable of running simple GLSL fragment shaders (but not vertex shaders) in hardware. I know this because a) documentation tells me so and b) the tools I were using tell me whether a shader is running in hardware or in software fallback mode.
With other words, someday I will see bump/specular-mapping on my laptop in Oolite? Great then, this will be a cool thing)
Ahruman wrote:
You get a rebate for the equipment that’s being replaced.
No, I think this was the integer overflow, a negative value that is then treated as unsigned int. Thats how I got millions of credits I guess...


P.S. 1.68 - runs smoothly without bugs so far, great work!
User avatar
JensAyton
Grand Admiral Emeritus
Grand Admiral Emeritus
Posts: 6657
Joined: Sat Apr 02, 2005 2:43 pm
Location: Sweden
Contact:

Re: Memory leak in version 1.70

Post by JensAyton »

Sardar wrote:
Probably that makes debugging a lot harder... Anyway, I think there should be a limit on memory to use, allocating and deallocating in large chunks, like Apache webserver does.

It is probably to late to change anything, but I think that scripting engine should be replaced by something more optimized. At least tail-recursion optimization is needed if recursion is extensively used.
It’s called the “legacy script engine” because it is being replaced. The old script system isn’t supposed to be able to recurse at all. In fact, it’s not Turing-equivalent. (Actually, the AI system is separate from the legacy script system, but they’re technically very similar.)
Ahruman wrote:
You get a rebate for the equipment that’s being replaced.
No, I think this was the integer overflow, a negative value that is then treated as unsigned int. Thats how I got millions of credits I guess...
Integer overflow from 8k to 4k? No.
Sardar
Average
Average
Posts: 9
Joined: Tue Dec 11, 2007 5:49 pm

Post by Sardar »

Integer overflow from 8k to 4k? No.
No, 4 * (10 ^ 8 ) -- sounds as hundreds of millions. Enough to buy the most expensive ship, but system doesn't allow me to do so. However buying less expensive stuff (around 20.000) is possible, while starting cash was only 8.000.
User avatar
Ark
---- E L I T E ----
---- E L I T E ----
Posts: 664
Joined: Sun Dec 09, 2007 8:22 am
Location: Athens Greece

Post by Ark »

Yesterday I install about 40 (including yaw ver 3 – tons of textures) oxps in 1.70, I ran the program and left it in the demo screen for about 30 minutes gazing the new ships. After that time everything started moving slower and slower. After that when I tried to load a save game I had I violent exit to windows. When I looked the stderr file the last message was:

Virtual memory exhausted

With 1,65 I had far more oxps installed (and a pc with much lower configuration) and I don’t recall such a thing

I don’t know if this is related with the memory leak mentioned in this thread.

Current configuration
Core Duo 2,4 Ghz
1 GB of ram
Nvidia Gforce 7600 GT
Windows Xp sp2
User avatar
Ark
---- E L I T E ----
---- E L I T E ----
Posts: 664
Joined: Sun Dec 09, 2007 8:22 am
Location: Athens Greece

Post by Ark »

Some observations that they may be related with memory leaks

The game sometimes freezes for about 5-10 minutes when I am trying to

1. Load a game
2. Die (I think this is related with the above)
3. Exit from withchspace

After that event in very few cases I have a violent exit to windows (the last line in stderr is "Virtual memory exhausted This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information." and the stdout is empty.but mostly I am able to exit myself (since after that that the game is unplayable).

When I open my pc usually I have about 700MB of free memory but after the above event I have 880MB (?? If someone could explain this to me??). After that the operating system is unstable and I have to reboot my machine.

It seems that the longer I am in the demo screen the more the changes for this (especially if I use the right – left arrow a lot of times). I think that definitely something is wrong with the demo screen since sometimes I can see some strange com logs (today I was able to hear sounds from customsounds OXP while in demo screen)


Some thoughts

I have about 70 oxps because I want to press 1.70 to its limits. Maybe is oxp related since without any OXPs is far more stable (but with the same OXPs 1.65 does not have that problem)

Maybe is “PC – Version” related.

Do not misunderstand me. My only intention is to help the Dev team

Current configuration
Core Duo 2,4 Ghz
1 GB of ram
Nvidia Gforce 7600 GT
Windows Xp professional sp2
another_commander
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 6628
Joined: Wed Feb 28, 2007 7:54 am

Post by another_commander »

The biggest memory leak in Oolite was identified a few days ago and was related to expanding description strings. This was mostly evident on the Short Range Chart screen, where, by just leaving it on for more than something like 5-10 minutes would cause memory exhaustion. See the Progress thread in Discussion for more detailed information. The good news is that this leak has been plugged already in the development builds.

Since this has been fixed, I have yet to see disk thrashing or freezes during game load, entering witchspace etc. Probably all these problems were related to that particular leak.
User avatar
Ark
---- E L I T E ----
---- E L I T E ----
Posts: 664
Joined: Sun Dec 09, 2007 8:22 am
Location: Athens Greece

Post by Ark »

Thanks for your reply another_commander
another_commander wrote:
This was mostly evident on the Short Range Chart screen, where, by just leaving it on for more than something like 5-10 minutes would cause memory exhaustion.
That’s odd since I only be there for a few seconds. Sometimes I have those problems from the beginning when I am trying to load a save game directly from the demo screen. It seems that the more oxps I have the more frequent is the problem (with 70 oxps loaded there is a 50% chance to have a violent exit from windows in a single route)
another_commander wrote:
Since this has been fixed, I have yet to see disk thrashing or freezes during game load, entering witchspace etc. Probably all these problems were related to that particular leak.
:D I am looking forward to it
User avatar
Ark
---- E L I T E ----
---- E L I T E ----
Posts: 664
Joined: Sun Dec 09, 2007 8:22 am
Location: Athens Greece

Post by Ark »

Ark wrote:
with 70 oxps loaded there is a 50% chance to have a violent exit from windows in a single route
It seems that by closing the f%&&& Norton antivirus auto protection and removing the nvidia control panel from system tray while playing oolite reduced that significantly (from 50% to 10%)
Sardar
Average
Average
Posts: 9
Joined: Tue Dec 11, 2007 5:49 pm

Post by Sardar »

Oolite 1.69
Config is the same (see first post).

Memory leaks when you fight others, usual limit is about 7-10 crafts. This happens only in dogfight (bomb can kill 40 without significant slowdown). If you do not encounter any craft (go 40 degree sideways from main route), then you may play for hour (tested) or more.
another_commander
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 6628
Joined: Wed Feb 28, 2007 7:54 am

Post by another_commander »

Ark wrote:
another_commander wrote:
Since this has been fixed, I have yet to see disk thrashing or freezes during game load, entering witchspace etc. Probably all these problems were related to that particular leak.
:D I am looking forward to it
Well, it happened again while testing the development build.:? Looks like we are not fully clear of it yet. Sorry...
Post Reply