How Do I Get Players Free HD Space and Total Memory?

I have been searching around for a while now but all I can find are things related to the size of the engine itself, out of memory issues or memory leaks. I have yet to find a way either in blueprints or C++ to do this.

FPlatformMemory and FPlatformMisc are both classes with static methods that you can use to get memory/disc/whatever info. Search for them in the code and you can see how they are used.

Thanks, do I need to add an import or anything to the ProjectName.Target.cs file?

Nope, its just part of the core engine so you shouldn’t need to add any extra project dependencies.

When I use FPlatformMemory::GetStats().TotalPhysical its is returning 1,997,864,960 however I have 8GB of RAM currently installed. What is this returning?

EDIT:
I also tried FPlatformMemory::GetPhysicalGBRam(); and I get the same response.

I placed these in functions I am exposing to blueprints. These are the values I am seeing in the blueprints.

Have you tried stepping through your Blueprint code (in C++) and seeing what those functions are returning vs what your blueprint method is returning? Maybe there is some strange conversion happening during that transition?

I don’t have access to my code to take a pic right now but from a blueprint widget I call the C++ function that returns FPlatformMemory::GetStats().TotalPhysical. The response from that is directly connected to a SetText node on a Text widget to be displayed in the UI. It does not go through any other processing in the blueprint before its shown. I do see from the docs that TotalPhysical returns some special type that I can’t seem to find right now. My C++ function returns an int32. Is there maybe something changing the value when it converts to an int32?

Yea, it doesn’t look like Blueprints support the types those methods return (FPlatform::GetStats.TotalPhysical is actually an unsigned long long which is a 64bit value - or more, depending on the platform). So if you just try to pass those values around, it’ll wrap around and you’ll get funky values. FPlatformMemory::GetPhysicalGBRam returns a uint32 but it should be small enough that you can safely convert it to an int32 in C++ before returning it.

1 Like