- Home /
Tracking cpu usage and memory for Web Player
Hi, Currently I am working on a game for the web player, a MMO so I would like to be able to track cpu usage and memory (free/used/etc..) and log it. I was trying to use PerformanceCounter as we use that on our server end for the same purposes but this class is not compatible with the Webplayer (per http://docs.unity3d.com/410/Documentation/ScriptReference/MonoCompatibility.html).
So I want to know if there is an existing API which can help in capturing this information on the client side? (This would be process level information i would assume)
Thanks.
Hm, I'm not sure if its even possible given that a webplayer has restricted access to the system.
But shouldn't it be possible to get some sort of access to current system resources that the process is consu$$anonymous$$g?
I just tried using Process to calculate it, but its not available in webplayer builds.
It would be nice to have that form of access, but it might be because of security that they have set a strict access to any part of the system.
@Ejlersen thanks.
Profiler can access a dev build of the game running in the web player, shouldn't there be some way of accessing it? (I couldn't find any resource on how the profiler does this)
You are right... Hm, might have an answer for you. Give me a $$anonymous$$ute.
Answer by Ejlersen · Aug 22, 2013 at 07:16 PM
Okay, might have something you can use:
GUILayout.Label("Total Allocated: " + Profiler.GetTotalAllocatedMemory());
GUILayout.Label("Total Reserved: " + Profiler.GetTotalReservedMemory());
GUILayout.Label("Total Reserved Unused: " + Profiler.GetTotalUnusedReservedMemory());
GUILayout.Label("Mono Heap: " + Profiler.GetMonoHeapSize());
GUILayout.Label("Mono Used: " + Profiler.GetMonoUsedSize());
Looks like the first three works fine in Webplayer.
thanks @Ejlersen that works. although its quite an expensive call and pretty much hangs the game for a good couple of seconds at least.
Profiler API does not have anything for tracking current CPU usage which is strange.
Well, Unity's profiler doesn't really track cpu usage, but it tracks how much time everything takes. You could probably get it to do that, but that's really expensive.