Jump to content

Memory leak & Memory cap Crash to desktop workarounds


Samlow

Recommended Posts

So in another thread I posted a concrete sollution to the current memory leak with temperature gauges. Since that thread was indeed a troll/whine thread, the fix probably deserves its own thread, and possibly a temporary sticky till its fixed.

The Problem

The problem stems from multiple causes.

- KSP 32 Bit has a memory limit of+-3.8 gigabytes of ram

This is a lmitation of 32 Bit programs.

KSP stock comes in at +-3.0 gigabytes of ram

- There is a memory leak involving temperature gauges

Which will slowly but steadily increase the allocated ram while you play.

Whilst the game itself plays stable, after a while (depending on your play session lenght) you will inevatibly crash to desktop. The error log will tell you that the game was not allowed to write to memory.

Plug that leak

Simple! Install the Temperature Gauge Killer

https://kerbalstuff.com/mod/775/Temperature%20Gauge%20Killer

This greatly reduces the rate at which KSP builds up RAM usage.

As sal_vagar pointed out as well, another way to fix this is by turning PPFX edge highlighting off (haven't tested this myself)

But Samlow! With mods I already start at 3.7 gigabytes!

Just like I did. Basically, if you play heavily modded (for an interstellar experience for example) you will be close to max ram usage even with the memory leak greatly reduced.

The sollution to this is to run the game in OpenGL. Yes, it will reduce your eye candy a bit, and doesn't like alt tabbing as much as windowed DirectX.

Please note, OpenGL is not the native running environment of Unity (the KSP game engine).

To run the game in OpenGL:

1 - Create a shortcut to KSP

2 - Open the shortcut properties

3 - add -force-opengl to the target line, all the way at the end, behind the bracket.

Your Target will end like this now:

KSP.exe" -force-opengl

But Samlow! Now its not as pretty and I dont have smooth edges!

Well, thats a result of the OpenGL render not having the high end settings that Direct X does.

The way to work around this is pretty simple too.

1 - Open your graphics driver software (Catalyst / Nvidia software)

2 - Find whatever tab controlls 3D program / game settings

3 - Add KSP to the list of custom settings

4 - Tweak the settings to be nice! (especialy Anti-Aliasing maxes a difference)

And youre done. The OpenGL version of KSP runs stock at about 2 Gigabyte of RAM, giving you a whole 1.8 Gigs of headroom before it will crash to the memory leak. Youd have to keep the game running for a day or two to do this. If you run modded, the game will not crash after 30 minutes anymore (unless you got buggy addons).

Edited by Samlow
Title reflecting actual content now
Link to comment
Share on other sites

This is nice Samlow, but turning off the PPFX edge highlighting will stop the leak too, and leaves you with a visual indication that you're getting hot before you blow up :)

Also, -force-opengl is an unsupported Unity3D game engine command which many players have found to be broken in the latest Unity4x release, so it is not recommended.

Some players have more luck with -force-d3d11 but expect weirdness.

Edited by sal_vager
Link to comment
Share on other sites

Thanks for that PPFX link, that will help a lot too!

But for me Im already running close to CTD due to heavy mod usage, so Im kind of forced into OpenGL. I have tried the d3d11 force as well, but that doesnt reduce memory load. Ill slightly adjust the title to reflect your suggestions!

Link to comment
Share on other sites

It might not look as good as before - although I have yet to compare screenshots, did not care just yet - but reducing the texture quality (correct text in the settings menu eludes me right now) by one step brought my game from 3.2GB at start (!) to 1.9GB and only climbing to 2.5GB after hours of playing.

(Using TemperatureGageKiller for now, but will try PPFX off today.)

Still, 3.2GB without that many part/beauty mods (KSPX, KAS, IR, USI LS, couple Kerbal heads, three suits, a simple galaxy and a new Kerbin texture, EVE, HotRockets) still frightens me!

Link to comment
Share on other sites

Thanks for the workaround OP!

But to be honest...in my opinion, a version 1.0 release hould never ever have had such a major issue with memory consumption/leakage! This should have been rammed out in a beta/alpha stage. But hell us spewing this on the forums was like preaching to the choire or talking to a wall.

Link to comment
Share on other sites

Thanks for the workaround OP!

But to be honest...in my opinion, a version 1.0 release hould never ever have had such a major issue with memory consumption/leakage! This should have been rammed out in a beta/alpha stage. But hell us spewing this on the forums was like preaching to the choire or talking to a wall.

1.0.x is what it is. There are solutions like the above or move to Linux and install more ram. The more people whine about what should of been and what should not have been unless you are develop of the game in question.

Link to comment
Share on other sites

To be helpful, rather than bitter (excuses for thah! ;) ), could this very helpful topic by the OP be stickied by a moderator?

This will will help a lot of players who run into this issue and do not know that this is causing it or how to fix it.

1.0.x is what it is. There are solutions like the above or move to Linux and install more ram. The more people whine about what should of been and what should not have been unless you are develop of the game in question.

Off topic: we, and you sir :), are entitled to voice our own opinions, wheter they are harse, whiny, bitter or sweet :)

Edited by Gkirmathal
to end positively
Link to comment
Share on other sites

1.0.x is what it is. There are solutions like the above or move to Linux and install more ram. The more people whine about what should of been and what should not have been unless you are develop of the game in question.

I strongly disagree with you, but partially agree. I agree that people shouldn't whine about features like the new aero, it's just game advancement. However, as a programmer myself, I think 1.0 was released too early. And as paying customers, it's expected that an out-of-beta 1.0 release be generally bug-free. A memory leak is a huge problem that should have been found during a testing period.

And while on the subject of memory issues; A 32-bit program that is limited by its own memory limitation should have much better memory management, especially since it's so easy to build huge ships that can bloat the address space available using only the stock game. Unloading unused objects out of memory, compression, loading on demand and disk caching methods should all be heavily used in order to avoid this problem.

I personally use the 64-bit Linux version, but I've been trying to use the Windows version because I expected it to be much more stable. Throwing workarounds at the game, and disabling things should not be a solution for a full release. Just like forcing someone to install Linux in order to play crash-free is also not a solution as some people just aren't that computer savvy, or they don't have the disk space, or whatever. I have suggested that people install Linux in the past, but again, that's not a solution, it's a workaround.

Like I said before, paying customers have every right to complain about an out-of-beta full version game that's still not stable. As for the previous Alpha and Beta versions, bugs were to be expected, that's why they were in Alpha and Beta, so there was nothing to complain about because you knew what you were downloading and paying for. Squad should have continued on with Beta versions 0.91, 0.92 etc until stability and memory issues were at least in the high 99%-ish range of fixes.

If a game developer wants to be in the business, they need to take care of their product. What do you think would happen if another big game dev came out with the next Halo, or Call of Duty or whatever and it kept crashing?

Edited by xtoro
Link to comment
Share on other sites

What do you think would happen if another big game dev came out with the next Halo, or Call of Duty or whatever and it kept crashing?

Charge you $25 for DLC that fixes it. Or make you wait until it is fixed in Call of Duty 15 Modern Warfare 7 Ultimate DLC Bundle Pack

Link to comment
Share on other sites

Eh. I feel like people have selective memory. So many major games have issues when they are released, you can never really cover every hypothetical situation without a truly stupid number of testers. It's very easy to look at a finished game and be critical of its flaws, yes, but can we at least admit that its practically impossible to code a game that will satisfy everybody?

Games that were released broken:

Halo 2 - Too many glitches to name. Some of those glitches turned out to be an instrumental part of gameplay.

Battlefield 4 - Crashed the game more times than I crashed a helicopter, for weeks and even months into the release

Skyrim & Oblivion - Need I say more :)

Fallout New Vegas - This is Oblivion level glitching. Falling through the surface of the planet? That's one of the nicer glitches.

Red Dead Redemption - 10/10 Horse Physics, 2/10 bugtesting

and thats just off the top of my head. How many of those games went on to become game of the year? Game of MULTIPLE years?

Patch 1.1 will come to fix the temp gauges if we're patient. Then we'll get Unity 5 for 64bit, multiplayer to spice things up, and hopefully a contract system that makes sense. Until then, workaround and carry on :)

Edited by OddFunction
Link to comment
Share on other sites

I hope the leak is plugged rather than the feature (temperature gauges) killed. I rather like monitoring the dissipation of heat. The feedback during re-entry is welcome and thought provoking.

Link to comment
Share on other sites

For the record, I'm not bashing KSP for having bugs, I'm saying it wasn't ready to be out of Beta yet. A memory leak is a huge problem that's easy to detect and should definitely be sought out in a program that already has "out of memory" crashes several versions back.

Link to comment
Share on other sites

For the record, I'm not bashing KSP for having bugs, I'm saying it wasn't ready to be out of Beta yet. A memory leak is a huge problem that's easy to detect and should definitely be sought out in a program that already has "out of memory" crashes several versions back.

You didn't come across as bashing to me. Your post looked thought out and your points are all valid. I just prefer to remain stupidly optimistic until I get obviously burned, and with SQUAD at least its worked out so far :)

Edit: Super early in the morning here so sorry if I screwed up the thread lol

Link to comment
Share on other sites

For the record, I'm not bashing KSP for having bugs, I'm saying it wasn't ready to be out of Beta yet. A memory leak is a huge problem that's easy to detect and should definitely be sought out in a program that already has "out of memory" crashes several versions back.

As the primary memory leak that I am aware of(heat bars) was not in the 1.0 release, but in a later release, it does not seem fair to use that particular memory leak as an indicator that 1.0 was ready or not.

Any time you add features, there is a risk of unforeseen problems, and as this added feature has a work-around(it can be disabled), and they had limited time before a planned code-freeze(aka the few days off to celebrate 1.0), I do not have a problem with the much-demanded feature being added, or that other, non-toggleable features might have received a greater portion of the available testing time.

Sure I have had my games crash from time to time(last night just after landing for example), but this is because I consider this feature more useful than the bother of re-loading the game.

(on the other hand, I have strongly considered removing a few mods, and possibly even using the 'unsupported' OpenGL flag to reduce memory usage)

Link to comment
Share on other sites

As the primary memory leak that I am aware of(heat bars) was not in the 1.0 release, but in a later release, it does not seem fair to use that particular memory leak as an indicator that 1.0 was ready or not.

Any time you add features, there is a risk of unforeseen problems, and as this added feature has a work-around(it can be disabled), and they had limited time before a planned code-freeze(aka the few days off to celebrate 1.0), I do not have a problem with the much-demanded feature being added, or that other, non-toggleable features might have received a greater portion of the available testing time.

Sure I have had my games crash from time to time(last night just after landing for example), but this is because I consider this feature more useful than the bother of re-loading the game.

(on the other hand, I have strongly considered removing a few mods, and possibly even using the 'unsupported' OpenGL flag to reduce memory usage)

There are other memory management issues other than the temp gauge memory leak.

For example, here's my usage (number in megabytes of RAM KSP is using):

1-Load the game : 1463

2-Load my save : 1630

3-Return to main menu : 1575 (why not the same as #1?)

4-Load save, go to SPH, load 95 part ship : 1795

5-Launch, revert to SPH, clear SPH (press new button), return to Space Center : 1838

6-Back to SPH, load same ship : 1880 (Why not same as #4?)

7-Launch, revert to SPH, clear SPH (press new button), return to Space Center : 1918 (Why not same as #5?)

8-Return to main menu : 1850 (Even more than #1 and #3, why?)

As you can see, the memory space is not being cleaned up. #1,3 and 8 should be much closer to the same memory usage. As well, 4 and 6 should be the same, and 5 and 7 should be the same. This may seem like small increments but they keep going up and up every time. Same goes with switching ships back and forth; the RAM usage keeps going up, so things aren't being cleaned up properly.

Another issue that I mentioned before is something as simple as Active Texture Management. It's a mod that compresses the textures used by the game. ATM has been around for a while and does a great job of reducing RAM usage simply by compressing the images. Why hasn't this been implemented yet into the stock game? There's still lots of very basic memory management and optimization methods that have yet to be implemented that would make the game more stable.

Link to comment
Share on other sites

Im actually using Active texture management as well, and that still put me with just 200 mb headroom in directX, as I said, I run a lot of mods.

It is a good place to start if you're using a lot of parts mods though.

Link to comment
Share on other sites

Squad adopted Sarbians DSS loader method that is even better than Active Texture Management, thats why the 1.+ versions of KSP are so much better on the memory front. I don't even know if ATM would do anything anymore on the stock game.

Link to comment
Share on other sites

As you can see, the memory space is not being cleaned up. #1,3 and 8 should be much closer to the same memory usage. As well, 4 and 6 should be the same, and 5 and 7 should be the same. This may seem like small increments but they keep going up and up every time. Same goes with switching ships back and forth; the RAM usage keeps going up, so things aren't being cleaned up properly.

Process memory usage isn't quite as simple as that. When the application code frees memory (or it is garbage collected due to having reached a 0 reference count), it is not necessarily returned to the OS. The first step is that it is returned to the application's "free list" (often much more complex than a simple single free list these days, with several pools for different size allocations). The application's memory management will only return memory to the OS in certain circumstances, otherwise it will keep the OS allocation and reuse it when it next needs memory for something. Also, with a language that uses garbage collection, the collection is not instant on every unload. Bottom line, while sustained growth over time probably is a memory leak, some of your observations may not be indicative of a memory leak, since you're using the OS allocation, not the application's internal memory allocator to measure it.

(load X; unload X) is not expected to necessarily return to the OS memory usage before X was loaded.

(for (i = 0; i < 1000; i++) { load X; unload X; }) OS memory usage with X loaded should not grow with every iteration of the loop, significant repeated growth on every iteration indicates a possible memory leak, but it doesn't necessarily follow that the memory usage should be exactly flat over every iteration of the loop, as things like fragmentation of the free memory may require the application's allocator to request more memory from the OS to make a suitable size block available for an object (despite the application overall having sufficient free memory for the object).

Link to comment
Share on other sites

Eh. I feel like people have selective memory. So many major games have issues when they are released, you can never really cover every hypothetical situation without a truly stupid number of testers. It's very easy to look at a finished game and be critical of its flaws, yes, but can we at least admit that its practically impossible to code a game that will satisfy everybody?

Games that were released broken:

Halo 2 - Too many glitches to name. Some of those glitches turned out to be an instrumental part of gameplay.

Battlefield 4 - Crashed the game more times than I crashed a helicopter, for weeks and even months into the release

Skyrim & Oblivion - Need I say more :)

Fallout New Vegas - This is Oblivion level glitching. Falling through the surface of the planet? That's one of the nicer glitches.

Red Dead Redemption - 10/10 Horse Physics, 2/10 bugtesting

Games that release full of bees happen fairly often... but those games also get called out on it (and die horribly if it's bad enough; see: Assassin's Creed: Unity). It doesn't usually make them bad games overall, but it IS bad development practices. I love KSP. I'll still call out problems like this. I'm hoping 1.0.3 will fix this next week.

Link to comment
Share on other sites

  • 7 months later...
On 2015-05-20 at 10:42 AM, Arsonik said:

Charge you $25 for DLC that fixes it. Or make you wait until it is fixed in Call of Duty 15 Modern Warfare 7 Ultimate DLC Bundle Pack

Exactly

Let alone, show me a game that hasn't been released with bugs in the past few years

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...