Jump to content

[KSP 1.7.2 incl all DLC's] KSP Memory Allocation Fix


Recommended Posts

So KSP actually 'USES' very little memory, it simply 'ALLOCATES' too much, that's the infamous 'memory leak' issue, though there were numerous memory leaks,the issue most describe is simply excessive allocation,where RAM usage inflates rediculously while in game or during start, an actuall memory leak is where an application uses more & more & more RAM non-stop until an eventual crash,the AHK script below is my solution to excessive allocation,this simple script is meant to be run Persistently,thought it acts only upon KSP, KSP  will have slightly less performance when alt-tabbing AND LONGER LOADING TIMES, but no performance impact otherwise while IN-GAME.

Script scrubs excess memory allocation every few sec,such allocation serves a legitimate purpose, but ksp seems to abuse it, which in low RAM systems means that windows is forced to page other applications & itself,slowing down the system as well, this in effect prevents ksp from make excessive allocations while allowing windows to remain responsive as well, while making KSP 'ALLOCATE' less memory.

Modset In Test(1.11GB): You'll notice, I Don't Run any clouds,got tired of the variable performance.

Spoiler


- ABCORS 0.5.0.4
- AblativeAirbrake 0.3.0
- AdvancedFlyByWire 1.8.1.3
- AECS-Motion-Suppressor 1.3.1
- AllYAll 1:0.11.17.1
- AntennaSleep 1.0.3
- Astrogator v0.9.2
- AtmosphereAutopilot v1.5.14
- AT-Utils v1.8.1
- AutoAction 1.10.7
- AutoAGL 1.1
- AviationLights v4.0.7
- B9PartSwitch v2.8.0
- B9-PWings-Fork 1:0.91
- BackgroundResources v0.13.12.0
- BasicDeltaV 5.2
- BasicOrbit 8.4
- BasicProceduralTextures v1.2
- BDAnimationModules 1:v0.6.5.7
- BetterBurnTime 1.9.1
- CapCom 2.10
- Chatterer 0.9.96
- ClickThroughBlocker 0.1.7.1
- CollisionFXUpdated 0.8.3.1.1
- CommNetVisualisation 1.0.4
- CommunityDeltaVMaps 2.6
- CommunityResourcePack 1.1.0.0
- ConfigurableContainers-Core 2.4.6.0.1
- ConstantTWR 0.0.4.3
- ConstellationEssentials v1.4.1.0
- ContractConfigurator 1.27.1
- ContractParser 8.0
- ContractsWindowPlus 9.2
- DangerAlertsContinued 1.4.4.3
- DangItContinued 0.7.18.2
- DeadlyReentry v7.7.2
- DecouplerShroud 0.7.1
- DefaultActionGroups 1.2.4
- DeployableEngines 1.0.1
- DistantObject v1.9.1.1
- DistantObject-default v1.9.1.1
* DockingCamKURS 1.3.5
- DockingPortSoundFX v2.1.12
- DockRotate v1.7.0.37
- DynamicBatteryStorage 2:1.4.2.0
- EasyVesselSwitch 1.11
- EngineLightRelit 1.6.0.4
- ESLDJumpBeacons 1.1.0
- ExperimentTracker 1:v1.3.4.5
- FanRadiator 0.2.0
- FilterExtensions 3.2.3.1
- FilterExtensionsDefaultConfig 3.2.3.1
- FirespitterCore v7.12.0
- FirespitterResourcesConfig v7.12.0
- FMRSContinued 1.2.7.4
- FTLDriveContinued 0.2.2
- FuseBoxContinued 0.1.16.8
- GravityTurnContinued 2:1.7.7
- GroundProximity 0.3.1
- HazardTanksTextures 1.0
- IndicatorLights 1.5
- IndicatorLightsCommunityExtensions 1.5
- InfernalRoboticsNext v3.0.0
- JanitorsCloset 0.3.5.1
- KAS 1.4
- KeepItStraight 1.0.7
- KerbalAircraftExpansion 3:2.8.0.1
- KerbalAlarmClock v3.10.0.0
- KerbalEngineerRedux 1.1.6.0
- KerbalHacksDroptankWrapper 1.0
- KerbalJointReinforcementNext v4.0.13
- KerbalKrashSystem 1:v0.4.7
- KSPWheel 15.13.32
A MakingHistory-DLC 1.7.1 (unmanaged)
- MarkIVSpaceplaneSystem 3.0.4
- MechJeb2 2.8.4.0
- MemGraph 1:1.1.1.8
- MiniAirbrakes 1.1
- MissingHistory 1.7.3
- ModularFuelTanks 5.12.3
- ModuleManager 4.0.2
- NavballDockAlignIndCE 1.0.4.4
- NearFutureConstruction 1.1.1
- NearFutureElectrical 1.0.1
- NearFutureElectrical-Core 1.0.1
- NearFutureElectrical-DecayingRTGs 1.0.1
- NearFutureLaunchVehicles 1.1.11
- NearFutureProps 1:0.5.1
- NearFuturePropulsion 1.1.1
- NearFuturePropulsion-XenonHETs 1.1.1
- NearFutureSolar 1.0.2
- NearFutureSolar-Core 1.0.2
- NearFutureSpacecraft 1.2.4
- ParkingBrake 0.1.2
- PlanetWiki making_CKAN_happy
- ProbeControlRoomRecontrolled 1.2.2.12
- ProceduralFairings 1:v1.6.1
- ProceduralParts v1.3.18
- ProgressParser 10.0
- PWBFuelBalancerRestored 0.1.5.9
- QuickSAS 1:1.1.4.2
- QuizTechAeroPackContinued 1.3.14.3
- RasterPropMonitor 1:v0.30.6
- RasterPropMonitor-Core 1:v0.30.6
- RCSLandAid 3.3.1.2
- RealPlume 2:v11.2.0
- RealPlume-StockConfigs v1.3.1
- RecoveryController 0.0.3.7
- ReentryParticleEffect 1.4
- RetractableLiftingSurface 0.1.5.5
- ScienceAlert 1.9.6.2
- SemiSaturatableRW 1:v1.6.1-1
- ShuttleLiftingBodyCormorantAeronology 1.5.1
- SignalDelay v0.2.9
- SmartParts 1.9.13.7
- SmartStage 1:2.9.11.2
- SmokeScreen 2.8.1.0
- SpeedUnitAnnex 1.3.5
- StockNoContracts v1.03
- surfacelights 1.13
- TACLS v0.13.12.0
- ThrottleControlledAvionics v3.5.7.0.1
- Timekeeper v1.0.1
- Toolbar 1.7.19
- ToolbarController 1:0.1.7
- Trajectories v2.2.2
- TriggerAu-Flags v2.9.3.0
- TweakScale v2.4.2.0
- TWR1 1.33.0.3
- unBlur v0.5.0
- UNDOCKINATOR v1.0.1
- USI-Core 1.1.0.0
- USI-NuclearRockets 1.1.0.0
- USITools 1.1.0.0
- VensStylePPTextures 1.1
- VesselView 2:0.8.7.2
- VesselView-UI-RasterPropMonitor 1:0.8.7.2
- WaypointManager 2.7.5
- WhoAmI 1.0.8
- WindTunnel 1.2.3
A ZeroMiniAVC (unmanaged)

 

 TEST RESULTS: (NOTE: Your Results May Vary depending on available GPU memory,as opengl & directx11 tend to allocate to graphics memory over system memory)

  • W/Out Script Running: KSP with 128Mods(1.11GB) & opengl starts up at 7GB of RAM & 8GB in VAB & >10GB during career playthrough to duna,eve & jool & back to kerbin(1hr...)
  • W/Script Running: KSP with 128Mods(1.11GB) & opengl starts up at 3.8GB of RAM & 4GB in VAB & 5-6GB during career playthrough to duna,eve & jool & back to kerbin(1hr...)
  • W/Out Script & W/Out Mods & Opengl:  starts up at 4.9GB of RAM & 5.3GB in VAB & 5-6GB during career playthrough  to duna,eve & jool & back to kerbin(accelerated time)
  • W/ Script & W/Out Mods & Opengl:  starts up at 3.5GB of RAM & 3.8GB in VAB & 4~5GB during career playthrough  to duna,eve & jool & back to kerbin(accelerated time)

KSP 1.7.2 including Making History & Breaking Ground, @1600*900 & Texture Quality at Half.  Windows 7 Ultimate x64

Intel(R) Core(TM) i7-2630QM CPU @ 2.5GHZ
x64-based PC
16384 MB
NVIDIA GeForce GT 720M v22.21.13.8528 @ -2048.00 MB RAM
Intel(R) HD Graphics 3000 v9.17.10.4229 @ -1988.00 MB RAM

 

Usage: Run script,then Run KSP, you'll find memory usage should be significantly reduced & excessive allocation non-existent while script is running. I recommend placing it in the Windows StartUp folder,it only ever acts on KSP so it won't cause issues.

 

NOTE:provided config allows setting frequency of  clearing working set in seconds, Lower is more aggressive & likely to make KSP slower, higher not so much. This script pretty much offers a trade, minor performance loss(during loading/scene switching) in return for significant reductions in memory usage, it does not affect actual gameplay performance,i.e, launching & blowing up stuff...

Source & Attachment are included in link below at AutoHotKey forums, post attachment includes compiled version of script in case you don't want to install AHK.

Source & Compiled Executable Download

^Previous Versions No Longer Deleted & can be found by visiting the forum link below, in case you find most recent update to be faulty.

Updated on 2019-08-17

  •  Fixed excessive system wide working set purge, that only happens once on script start now to increase memory pool for ksp & no longer happens when config is updated as well.

 

Updated on 2019-09-19

  • Added maxUsedMemPercent, allows ksp to remain more responsive, based on default settings, ksp working set is only cleared when system memory usage exceeds set maximum(70) percent AND every number of seconds(30) defined,also in config. Set 'maxUsedMemPercent=0', to simply clear working set every number of defined seconds irrespective of system memory usage..

AutoHotKey forums post

License: MIT and BSD Software Licenses

Edited by 0x00
Improved KSP Performance by means of an alternative logic to clearing working set.
Link to comment
Share on other sites

I'm not a moderator, but the first one here will tell you you need a license, both displayed on the forum and in the distribution file.

This looks cool. However, I never really have memory issues because ridiculously powerful computer and all :D Now if this solved KSP slowness issues, or actually stopped the memory leak from leaking (does it?) then that's another story.

However for the potatoes of the world this could be really cool Kudos!

Link to comment
Share on other sites

2 hours ago, 5thHorseman said:

I'm not a moderator, but the first one here will tell you you need a license, both displayed on the forum and in the distribution file.

This looks cool. However, I never really have memory issues because ridiculously powerful computer and all :D Now if this solved KSP slowness issues, or actually stopped the memory leak from leaking (does it?) then that's another story.

However for the potatoes of the world this could be really cool Kudos!

Technically speaking, he is linking to a post on another forum, which has the program.  This is akin to my posting a link to MS Office page

however, explicitly posting a license certainly wouldn't hurt.

I also question the results.  Loading the game is not the same as playing the game.  Really need to see what happens longterm.  Try using Memgraph to see what happens over time:

 

Edited by linuxgurugamer
Link to comment
Share on other sites

6 hours ago, steuben said:

You sure it's KSP and not the mods? Try it with stock and report back the numbers.

You've got 130 mods there so I wonder if they aren't magnifying any gains you might be getting.

See updated post,and i made sure to test stock beforehand, inferior results from the outset convinced me otherwise. And besides no one plays stock,so beside excluding mods as the cause for my perceived gains/loses,i saw no reason for extended testing given the stock performance at the start screen,let alone during gameplay.

5 hours ago, 5thHorseman said:

I'm not a moderator, but the first one here will tell you you need a license, both displayed on the forum and in the distribution file.

This looks cool. However, I never really have memory issues because ridiculously powerful computer and all :D Now if this solved KSP slowness issues, or actually stopped the memory leak from leaking (does it?) then that's another story.

However for the potatoes of the world this could be really cool Kudos!

License included, and It is indeed for potato machines,but it's useful nonetheless, I've got plenty of RAM,but never enough to run ARMA 3 & KSP simultaneously,with it,i can.... AND NO,testing was not under those conditions,just something i like to do occasionaly when i'm in the mood for both,shoot russians & fly kerbals.

3 hours ago, linuxgurugamer said:

Technically speaking, he is linking to a post on another forum, which has the program.  This is akin to my posting a link to MS Office page

however, explicitly posting a license certainly wouldn't hurt.

I also question the results.  Loading the game is not the same as playing the game.  Really need to see what happens longterm.  Try using Memgraph to see what happens over time:

 

It was my mistake,by 'kerbal stuff', i was attempting to describe game play, I've clarified. I don't however know how to describe the results of memgraph,other than to say the Max Heap size is lower with, than without,not by a large margin though, and it also tends to decline after increasing in value more so with the script running,where as it remains fairly constant with out the script.

2 hours ago, Gargamel said:

We are looking into the Licensing issue, and this has been moved to add-on discussion. 

License included,I didn't know third-party tools were classified as addons,hence why i posted it where i did originally.

Link to comment
Share on other sites

1 hour ago, 0x00 said:

And besides no one plays stock

No one, like never, is a word used more frequently than wisely. An aborted test is not a result for or against a position. It is an empty result. My question remains.

Link to comment
Share on other sites

9 hours ago, 0x00 said:

,no ksp player actually plays like that,

Let me direct your attention to the two most popular KSP players on Twitch, EJ & DasValdez.  EJ plays pure stock, and does amazing things.  Das will use a few mods, but nothing exotic.

I would also wager that the majority of people who play never log on to the forums, and never play with mods.  The forums are obviously a place where mods are discussed, and it makes sense that those players who are active in the community, will also have a better chance of using mods.

Thanks for adding the license, it's appreciated

Link to comment
Share on other sites

42 minutes ago, steuben said:

No one, like never, is a word used more frequently than wisely. An aborted test is not a result for or against a position. It is an empty result. My question remains.

 

34 minutes ago, linuxgurugamer said:

Let me direct your attention to the two most popular KSP players on Twitch, EJ & DasValdez.  EJ plays pure stock, and does amazing things.  Das will use a few mods, but nothing exotic.

I would also wager that the majority of people who play never log on to the forums, and never play with mods.  The forums are obviously a place where mods are discussed, and it makes sense that those players who are active in the community, will also have a better chance of using mods.

Thanks for adding the license, it's appreciated

I stand corrected, I've amended my comments & done a stock test to reflect as much. I knew there were 'stock' tropes on YouTube, though challenges more than an actuall way to enjoy the game, but i never considered why anyone would want to play stock & 'NO ONE' was to strong a phrase, cheers.

Link to comment
Share on other sites

  • 2 weeks later...

Mebbe cuz its in *Add-on Discussions*, instead of Add-On Releases, or even Add-On Development, one of which, where it should really probably be, instead of Discussions .. vOv
@0x00 Mebbe you should ask to have it moved?
I'm a *long time* mod hoarder, and I've never heard of this before nao...

Also, I am on a potato... (slightly lower CPU and Nvida GPU stats), but otherwise the same as 0x00 poasted that he has...
I think I'll definately give this a try, now that I've discovered it ... :P

Edited by Stone Blue
Link to comment
Share on other sites

1 hour ago, RealKerbal3x said:

@0x00 Does this script require forcing OpenGL? The OP doesn't make that clear. Otherwise, this looks great, since my computer definitely falls under the category of 'potato' and I always have performance problems.

Note really, but opengl already provides great reductions in memory usage, so it improves on opengl gains,though doesn't depend on it, you could just as well use directx11.

1 hour ago, Stone Blue said:

Mebbe cuz its in *Add-on Discussions*, instead of Add-On Releases, or even Add-On Development, one of which, where it should really probably be, instead of Discussions .. vOv
@0x00 Mebbe you should ask to have it moved?
I'm a *long time* mod hoarder, and I've never heard of this before nao...

Also, I am on a potato... (slightly lower CPU and Nvida GPU stats), but otherwise the same as 0x00 poasted that he has...
I think I'll definately give this a try, now that I've discovered it ... :P

 

@Gargamel Could you please move this thread to Add-On Releases.

Edited by 0x00
Link to comment
Share on other sites

If I'm understanding correctly, this is not a KSP mod that runs in-game, but actually an external tool?

In that case, it's not an add-on, but it is a tool.  Moving to Tools & Applications.

Link to comment
Share on other sites

5 minutes ago, Snark said:

If I'm understanding correctly, this is not a KSP mod that runs in-game, but actually an external tool?

In that case, it's not an add-on, but it is a tool.  Moving to Tools & Applications.

Indeed it's not a mod & I didn't even know that was a section, although i think fewer people might find it there, so perhaps this is the best place for it in retrospect.

 

As the functionality is a basic DllCall,  if anyone can implement this as a dll that could be loaded from within ksp it would be most useful i think, and perhaps most convenient. @linuxgurugamer, ur the lord of mods, care to give it a shot, i reckon more people would use it if it were a dll plugin, it's simply a matter of clearing the working set at a fixed interval, pretty much this function https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-setprocessworkingsetsize.

Link to comment
Share on other sites

3 minutes ago, 0x00 said:

Indeed it's not a mod & I didn't even know that was a section, although i think fewer people might find it there, so perhaps this is the best place for it in retrospect.

 

As the functionality is a basic DllCall,  if anyone can implement this as a dll that could be loaded from within ksp it would be most useful i think, and perhaps most convenient. @linuxgurugamer, ur the lord of mods, care to give it a shot, i reckon more people would use it if it were a dll plugin, it's simply a matter of clearing the working set at a fixed interval, pretty much this function https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-setprocessworkingsetsize.

Where is your source code? Prefrerably this mod tool should be accesble as a configyration setting in KSP

Edited by FreeThinker
Link to comment
Share on other sites

1 hour ago, 0x00 said:

Indeed it's not a mod & I didn't even know that was a section, although i think fewer people might find it there, so perhaps this is the best place for it in retrospect.

 

As the functionality is a basic DllCall,  if anyone can implement this as a dll that could be loaded from within ksp it would be most useful i think, and perhaps most convenient. @linuxgurugamer, ur the lord of mods, care to give it a shot, i reckon more people would use it if it were a dll plugin, it's simply a matter of clearing the working set at a fixed interval, pretty much this function https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-setprocessworkingsetsize.

LOL, considering I'm have a new mod in beta, HeapPadder, which does the opposite of what this does.

59 minutes ago, FreeThinker said:

Where is your source code? Prefrerably this mod tool should be accesble as a configyration setting in KSP

It's a small script for AutoHotkey, would be easy enough to do in KSP, I suppose

Link to comment
Share on other sites

38 minutes ago, linuxgurugamer said:

I have no idea,  why dont you try it and report back.

 

I have been using this with memgraph with no issues so far besides maybe slightly longer loading times and slight stutter when you open the game but i have to uninstall memgraph to confirm them as i installed a few more mods at the same time i installed memgraph

Link to comment
Share on other sites

On 7/18/2019 at 9:58 PM, linuxgurugamer said:

LOL, considering I'm have a new mod in beta, HeapPadder, which does the opposite of what this does.

So the space savings here are from reduced mono heap sizes? If so, wouldn't that increase GC stutter frequency with this?

Link to comment
Share on other sites

Just now, Jognt said:

So the space savings here are from reduced mono heap sizes? If so, wouldn't that increase GC stutter frequency with this?

Apparently not.  From what I saw, itz releasing unused memory back to Windows.  It will cause slowness  when changing scenes 

Link to comment
Share on other sites

Just now, linuxgurugamer said:

Apparently not.  From what I saw, itz releasing unused memory back to Windows.  It will cause slowness  when changing scenes 

Ahh, so no actual changes except that KSP has to ask windows "plz sir, can I have some more RAM?" every once in a while. Sounds good!

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...