This project is read-only.

Nuclex.UserInterface using 132mb memory per screen

Jan 23, 2011 at 3:51 PM

I just performed a memory profile on my application that is using the Nuclex.UserInterface.  The class Nuclex.UserInterface.Screen is using 132mb per instance.  This is all tied up in BitArray heldKeys.  I'd change it myself but I can't get the Nuclex.UserInterface project to compile.  It's missing the embedded content file.

Jan 24, 2011 at 1:21 AM
Edited Jan 24, 2011 at 1:23 AM

In my tests, the Screen.heldKeys BitArray has a size of 8 bytes (maxKeyboardKey is 254, so the BitArray is initialized to hold 254+1 bits, which fit in 8 bytes). If I execute Nuclex.UserInterface.Demo.exe, the entire process with all resources reaches a size of no more than 16.5 MiB. How are you profiling memory usage and on which platform?

-

Regarding the compiling issue:

Have you tried compiling it or just seen some resources /apparently/ missing and ? The library includes some .xnbs used in the built-in skin as resources, but these .xnb files are only generated right before the project builds, so they will be displayed as missing on a clean checkout.

Or could it be that you checked out the project on its own (without the required dependencies) instead of the workspace found at https://devel.nuclex.org/framework/svn/Framework.Build/trunk? Did you use the build script (framework.build) or, otherwise, manually compile the font processor (Nuclex.Fonts.Content.TrueTypeImporter) in Visual C++ 2010 Express before compiling the Nuclex.UserInterface project?

I am running a continuous integration server at https://devel.nuclex.org/teamcity/guestLogin.html?guest=1 that does clean builds of the entire source tree whenever I commit changes to my Subversion repository. The project compiles fine there and passes all tests, so I'm pretty sure the SVN sources are in a compileable state!

Jan 24, 2011 at 3:33 AM

I downloaded the 14-day trial of the ANTS profiler to profile it.  It says that there is a int32 arrays in Nuclex.UserInterface.Screen of about 134mb.  This is the bulk of the memory usage of my game.  I'm using the binaries that came with the version that was released on Thursday September 30, 2010.  

 

I've tried opening up the "Framework (xna-4.0-86)" solution in Nuclex/source/framework and it is missing several resources.  I didn't use the framework.build file.  I have absolutely no idea what it is.  I'm self taught on programming and I haven't done any collaboration or sharing with other developers.

Jan 24, 2011 at 2:01 PM

Ah, I somehow concluded that you were using the SVN trunk, sorry.

I just downloaded the source release from CodePlex, first compiled Nuclex.Fonts.Content.TrueTypeImporter, then the Framework solution with 0 warnings, 0 errors. There were no missing resources. My best guess is that you didn't compile the true type importer first and it's a followup error you're seeing (as I said some assets included as resources are built using the true type importer). If you don't have Visual C++ 2010 Express or one of the bigger Visual Studio editions, you can copy the true type importer binary from the binary distribution into the appropriate directory (Nuclex.Fonts.Content.TrueTypeImporter/bin/xna-4.0-x86/Release).

I'll make sure to include a precompiled version of the true type importer in the next release to make compiling easier.

-

I'm going to download the ANTS trial myself and see if I can spot the issue. Will report back!

Jan 25, 2011 at 1:05 AM

I've added the TrueTypeImporter reference but still have these two errors when trying to compile:

 

Error 1 Invalid Resx file. Could not find a part of the path 'C:\Users\Newtons.Bit\Documents\Visual Studio 2010\Projects\Quill\$Nuclex\source\framework\Nuclex.UserInterface\bin\EmbeddedContent\Skins\Suave\DefaultFont.xnb'. Line 123, position 5. C:\Users\Newtons.Bit\Documents\Visual Studio 2010\Projects\Quill\$Nuclex\source\framework\Nuclex.UserInterface\Resources\SuaveSkinResources.resx 123 5 Nuclex.UserInterface (xna-4.0-x86)

 

Error 2 Invalid Resx file. Could not find a part of the path 'C:\Users\Newtons.Bit\Documents\Visual Studio 2010\Projects\Quill\$Nuclex\source\framework\Nuclex.UserInterface\bin\EmbeddedContent\UnitTest\UnitTestFont.xnb'. Line 132, position 5. C:\Users\Newtons.Bit\Documents\Visual Studio 2010\Projects\Quill\$Nuclex\source\framework\Nuclex.UserInterface\Resources\UnitTestResources.resx 132 5 Nuclex.UserInterface (xna-4.0-x86)

 

Feb 5, 2011 at 4:57 PM
Edited Feb 5, 2011 at 5:00 PM

I have tried the following:

  • Started a Virtual Machine with just a fresh install of Windows 7 x86
  • Installed Visual C# 2010 Express
  • Installed XNA Game Studio 4.0 Express
  • Unpacked the Nuclex Framework sources R1242
  • Copied over the TrueTypeImporter from the R1242 binary distribution
  • Opened "Framework (xna-4.0-x86).sln" and compiled

No issues, same as on my workstation.

I have just published a new release and this time included a prebuilt Nuclex.Fonts.Content.TrueTypeImporter.dll in the Source distribution. The only step required to compile now is to open the solution and hit compile.

-

For the memory issue, I downloaded ANTS Memory Profiler 6.0 and ran the Nuclex.UserInterface.Demo executable in it:

The memory usage remains at one and a half MiB during the whole run. I took a snapshot and looked for the screen class:

There's one instance, using 48 Bytes. Sorry, I can't figure out any issues in my code. If you wish, you could send me your profiling data. You can find mine here: http://hotfile.com/dl/102154427/adf0996/Nuclex.UserInterface.Demo-AntsProfiler.7z.html

Some other things to check: using Nuclex.Support.EnumHelper class from the Nuclex.Support library, what does EnumHelper.GetHighestValue<Microsoft.Xna.Framework.Input.Keys>() evaluate to? On my system, it's 254.

Do you observe the same memory usage initializing a BitArray with 255 elements like this: var heldKeys = new BitArray(255);? For me, it uses 8 bytes of memory.

Feb 5, 2011 at 5:18 PM

Replace any instance of "ANTS Memory Profiler 6.0" with "ANTS Memory Profiler 7.0" in my previous post. Until today, 6.0 was the most recent release I checked out :)