Closed erhavir closed 5 years ago
Sorry. I made a mistake above. For instance, when I was using 2.4 Gb, 1.4 Gb was available and the total was 3.8 Gb. None of the values in Device Portal showed 2 Gb, while 2048.0 Mb was shown as the limit.
Note that the diagnostic tools use the unity SystemInfo.systemMemorySize API, which are documented to not work on UWP. On UWP it uses AppMemoryUsageLimit, which is a sandboxed version of memory information (i.e. we report what the system reports.
This is a limitation of the UWP platform itself - the app can only show what it is told its limits are, as it isn't told anything about the overall system.
@erhavir, do you think it would be better in this case to NOT show the upper limit (i.e. just show current usage?)
I think showing usage is helpful. It sure helped me when I was hitting against upper limits. Since there are MRTK profiles for HoloLens 1 and HoloLens 2, do you think we could make that upper limit a part of the profile since the memory limits are fixed and we know what they are? In the case of other platforms, such as running on PC in editor or on other MR devices that wouldn't be possible. Do we know the end-point that they are on when displaying the panel?
We don't actually know the end point when things are running on device (there are numerous threads internal and external about why UWP doesn't allow for this, so it's not worth going down that rabbit hole).
However, the concept of having an "override" for a particular platform (i.e. a hololens1visualprofile.asset) which hardcodes the memory on device seems reasonable.
For other UWP (i.e. VR) applications we'd still be stuck with the current 2048 number or whatever the system reports.
FYI @Cameron-Micka since he built the visual profiler
Hey @erhavir, if you look at how the Visual Profiler calculates the maximum memory it uses the method @wiwei mentions above: https://github.com/microsoft/VisualProfiler-Unity/blob/master/VisualProfiler.cs#L698 I'm curious how you were able to go above this limit? Usually when I see Unity apps go above that threshold they crash due to unhandled out of memory exceptions. I would be hesitant to hardcode memory size into MRTK profiles since nothing stops users from using them on other platforms.
It would be interesting to see what Unity's SystemInfo.systemMemorySize returns in UWP apps?
@Cameron-Micka I think on UWP apps it will:
Windows Store Apps: This function is not supported on Windows Store Apps and will always return 0.
Per https://docs.unity3d.com/ScriptReference/SystemInfo-systemMemorySize.html
Ah, I didn't catch that! That must be why I added a special case for UWP. Do we know from the platform team if there is a more appropriate method to use if this one is reporting an inaccurate ammount?
I think that this is the only API we can use.
AFAIK the platform intentionally doesn't expose the underlying system RAM information so as to not leak information about the system.
Another idea may just be to say "App Limit" instead of "Limit" to be clear it's the limit for the app. I don't know if we should really go down a path of working around underlying system APIs for querying system memory.
Sounds good to me, seems like we should report this issue to the platform team because as a developer I would assume: MemoryManager.AppMemoryUsage is always <= MemoryManager.AppMemoryUsageLimit
Overview
The Profiler shows a max memory of 2048 Mb on HoloLens 2. I just went over that (2.6 Gb) and the blue line went off the edge of the profiler. 2048 Mb was also the noted limit in the profiler. it does show a higher limit when I run the project on my PC.
Noted in the device portal, Available is 2048 Mb. However, it's nearly double that for total, and I am using more than Available.
Expected Behavior
The Profiler should show the actual top limit of memory available on the system.
Actual Behavior
The Profiler shows less than the available memory on the system.
Steps to reproduce
Unity Editor Version
2018.4.1.8f1
Mixed Reality Toolkit Release Version
MRTK 2.0.0