sarbian

[1.2.1] GCMonitor 1.4.7.1 - A graphic Memory monitor (February 5th)

262 posts in this topic

I was looking into some memory usage related things for MechJeb2 and wanted a tool to display a graphic of the memory usage. So I made one.

ALT + F1 to hide/show the window

Change for 1.2

- Now include a native library to get the memory usage of the whole KSP process.

- Relative mode that graph increase and decrease of the memory

- FPS and memory counter (ALT + F to show hide). It should change color on x86 when getting near the limit

- Fixed a bug that could crash the game at random. duh.

1.2.2

- Fix OSX detection

- Fix Window requiring the debug dll

1.2.3

- AppLauncher and Blizzy Toolbar support. Right click open the window and Left click switch the memory / FPS counter

- "Top" button to set a fixed point to compare with.

- Setting saved into a file after first use.

- Icon change with the used memory. If you want to change the warning and alter limit edit the file in "GameData\GCMonitor\PluginData\GCMonitor" and change warnPercent & alertPercent

- AVC file included but not tested

1.2.4

- new method for the FPS counter

- options to move, resize and hide the FPS and Mem counter

- Config window to set the new options

1.2.5

- include dll for KSP x64 on windows

- fix the inverted FPS and Memory option

1.2.6

- On Windows uses the Virtual Memory size instead of the RSS for the KSP memory use. You will get larger numbers but they are more relevant to the 4GB limit.

1.2.7

- Fix the false alert on Linux

- hide the UI / Display on F2

Compiled Native lib included for Windows, OSX and Linux x64

The source for that lib are also in the zip for those who want to compile. A quick look at the cs source will show you how the lib need to be named. Search for the "[GCMonitor]" in the log to see if it worked.

About the Reported value when KSP process is not checked:

- this report the Managed memory space of mono. This is why it report low number like 200MB. This is only the memory used by the C# part of the game and plugins. It does not include the texture, models and those stuff.

- Mono use a garbage collector system so the sawtooth graph is normal. Memory grow until the garbage collector clean it up (it's actually a bit more complex but ... )

- The gray area is the minimum reported memory in an interval. The green one is the maximum. So it a lot of memory is used or freed in an interval you get green area

- The red line at the bottom is how many time the garbage collector ran in the interval (10px per time).

1.2.8-1.4.1

- Stuff

1.4.2

- lowered the memory usage to 84B per frame with the counters displayed and about 900B per frame with the window open. I don't think I can get it much lower.

1.4.3

- fix the counters moving with the app scale

1.4.4 

- fix a memory use related to the FPS/Memory displays that @Padishar detected a long teim ago but I could not track down before;

1.4.5

- fix the config button....

1.4.6

- Lower memory garbage with the GPU monitoring. Thanks to @Padishar

- Switch to custom code to load the asset bundle so the UI is available for the start

- an other attempt at fixing the OSX memory detection

1.4.7.x : KSP 1.2 update

Download : GCMonitor-1.4.7.1.zip

Source : https://github.com/sarbian/GCMonitor and https://github.com/sarbian/KSPUIHelper

License : MIT and CC0 for the native lib

And now awesome pictures, because this is how we sell plugin around here :

GCM-FPS.png

GCMonitor.png

Edited by sarbian
12 people like this

Share this post


Link to post
Share on other sites

very handy tool thx

hope you come up with a way to display memory usage like in the task manager so we can see the actual memory usage of ksp + mods :)

Share this post


Link to post
Share on other sites

Nice useful utility. Well done :).

Share this post


Link to post
Share on other sites
- I have no idea on how to do the same thing for the memory used by texture and such. If anyone has tested way to get those info with a plugin feel free to share.

Really hope someone can help out here. It would be great to see what my biggest memory users are for textures

Share this post


Link to post
Share on other sites

Nice, it could be even better by providing a grid with some scale value (dynamic or static), a major line every 100 MB, minor every 10 MB for example.

Share this post


Link to post
Share on other sites

Some comments.

The grey looks plain. Suggesting a colur option.

And a average line or bar so that no flutuations occur :D

Share this post


Link to post
Share on other sites
The grey looks plain. Suggesting a colur option.

This is not an art contest.

1 person likes this

Share this post


Link to post
Share on other sites
And a average line or bar so that no flutuations occur :D

If you ask for an average then I don't think you understand the utility of this or how managed memory works.

Share this post


Link to post
Share on other sites
Nice, it could be even better by providing a grid with some scale value (dynamic or static), a major line every 100 MB, minor every 10 MB for example.

a graph without scale should be ignored

Share this post


Link to post
Share on other sites
If you ask for an average then I don't think you understand the utility of this or how managed memory works.

Not to argue.

I KNOW how this works.

Share this post


Link to post
Share on other sites

As asked I added a new mode with more color. new DL in first post. Be careful because I removed the version number from the dll, so you have to delete the old one.

a graph without scale should be ignored

Come back when you have some code to write text on a Texture2D that is not longer than the whole actual plugin. Some things seems really simple but are not.

Share this post


Link to post
Share on other sites

This is a really great tool sarbian! Helped me profile and optimize the memory usage of my plugin after I saw this thread about Unity memory management.

Edited by Uzza

Share this post


Link to post
Share on other sites

Thanks - this helped me a lot in diagnosing my memory leak :)

Share this post


Link to post
Share on other sites

Very cool. more instrumentation is always better. Thanks for all your hard work.

Share this post


Link to post
Share on other sites

And again, Sarbian delivers gold...

Thanks, great mod.. Helps to find 'bloat' and other issues.

Share this post


Link to post
Share on other sites

Shoot! This is almost exactly what I need! Shame you can't see graphic assets like texture space.

Share this post


Link to post
Share on other sites

Just to be clear on how to use this, I plop the GCMonitor.dll file into my root KSP folder, or the GameData folder? Or a GCMonitor subfolder within my GameData folder?

Share this post


Link to post
Share on other sites

Anywhere in GameData works.

Share this post


Link to post
Share on other sites

Any chance to get this CKAN compatible?

Share this post


Link to post
Share on other sites

Released 1.2 with KSP real memory usage thingy and a Kitty.

- Now include a native library to get the memory usage of the whole KSP process.

- Relative mode that graph increase and decrease of the memory

- FPS and memory counter (ALT + F to show hide). It should change color on x86 when getting near the limit

- Fixed a bug that could crash the game at random. duh.

Compiled Native lib included for windows x86 (and Linux x64 but not tested).

The source for that lib are also in the zip for those who want to compile. A quick look at the cs source will show you how the lib need to be named. Search for the "[GCMonitor]" in the log to see if it worked.

*Kitty not included in all zip

Edited by sarbian
1 person likes this

Share this post


Link to post
Share on other sites
Released 1.2 with KSP real memory usage thingy and a Kitty.

- Now include a native library to get the memory usage of the whole KSP process.

- Relative mode that graph increase and decrease of the memory

- FPS and memory counter (ALT + F to show hide). It should change color on x86 when getting near the limit

- Fixed a bug that could crash the game at random. duh.

Compiled Native lib included for windows x86 (and Linux x64 but not tested).

The source for that lib are also in for those who want to compile. A quick look at the cs source will show you how the lib need to be named. Search for the "[GCMonitor]" in the log to see if it worked.

*Kitty not included in all zip

Waw HUGE, it makes my MemoryUsage mod useless (on which I've planned to add an update ... but now I don't know if I will keep it alive) ;)

(and GCMonitor works fine on linux x64).

Edited by Malah
grammar

Share this post


Link to post
Share on other sites

Having a problem. The KSP Memory stays at zero and never changes.

Here's the snip from the output.log


Load(Assembly): GCMonitor/GCMonitor

(Filename: C:/BuildAgent/work/d63dfc6385190b60/artifacts/StandalonePlayerGenerated/UnityEngineDebug.cpp Line: 49)


AssemblyLoader: Loading assembly at F:\Program Files (x86)\Steam\steamapps\common\Kerbal Space Program\GameData\GCMonitor\GCMonitor.dll

(Filename: C:/BuildAgent/work/d63dfc6385190b60/artifacts/StandalonePlayerGenerated/UnityEngineDebug.cpp Line: 49)


Load(Assembly): GCMonitor/getRSS_x86

(Filename: C:/BuildAgent/work/d63dfc6385190b60/artifacts/StandalonePlayerGenerated/UnityEngineDebug.cpp Line: 49)


AssemblyLoader: Loading assembly at F:\Program Files (x86)\Steam\steamapps\common\Kerbal Space Program\GameData\GCMonitor\getRSS_x86.dll

(Filename: C:/BuildAgent/work/d63dfc6385190b60/artifacts/StandalonePlayerGenerated/UnityEngineDebug.cpp Line: 49)


Failed to load assembly F:\Program Files (x86)\Steam\steamapps\common\Kerbal Space Program\GameData\GCMonitor\getRSS_x86.dll:
System.BadImageFormatException: Format of the executable (.exe) or library (.dll) is invalid. at Mono.Cecil.PE.ImageReader.ReadOptionalHeaders (System.UInt16& subsystem, System.UInt16& dll_characteristics) [0x00000] in <filename unknown>:0 at Mono.Cecil.PE.ImageReader.ReadImage () [0x00000] in <filename unknown>:0 at Mono.Cecil.PE.ImageReader.ReadImageFrom (System.IO.Stream stream) [0x00000] in <filename unknown>:0 at Mono.Cecil.ModuleDefinition.ReadModule (System.IO.Stream stream, Mono.Cecil.ReaderParameters parameters) [0x00000] in <filename unknown>:0 at Mono.Cecil.ModuleDefinition.ReadModule (System.String fileName, Mono.Cecil.ReaderParameters parameters) [0x00000] in <filename unknown>:0 at Mono.Cecil.ModuleDefinition.ReadModule (System.String fileName) [0x00000] in <filename unknown>:0 at AssemblyLoader.ScanForBadTypeRefs (System.String file) [0x00000] in <filename unknown>:0 at AssemblyLoader.LoadExternalAssembly (System.String file) [0x00000] in <filename unknown>:0




Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now