Chryso

Hello,

I am trying to see why my application has some performance issues. So I dowloaded the CLR Profiler for .NET 2.

And now it is saying that I am allocating some enum variables and here is the line code that does it if I interpret correctly the allocation sequence of the profiler:

return WindowsGame.Game1.localization.localText[WindowsGame.Game1.lg][Localization.enumText.startGame];
local text has the following format:
SortedList<enumLanguage, SortedList<enumText, string>>

Maybe I am doing this the wrong way, but using enums for localization is just a great help instead of strings or ints since you can not make any typos or always need to check if the int you are looking for is the right one.
So the list is initialized from an XML file on start.

Question is, why does the CLR Profiler informs me that I am allocating lots of enumeration type

Regards,
Chryso




Re: Common Language Runtime Enumeration, garbage collecting and allocation

nobugz

I seriously doubt you have an issue with enums, they are value types and don't get stored on the GC heap. Looks to me that the profiler is telling you you have a lot of SortedList<> instances. Note that CLR Profiler isn't a good tool to trouble-shoot performance issues. It profiles memory usage, not execution performance. The poor man's code profiler is System.Diagnostics.StopWatch.





Re: Common Language Runtime Enumeration, garbage collecting and allocation

Chryso

Mmm,
Thanks for the clear up.
Though I only have one SortedList of that type and I thought that access in it was O(1)

Would you know more Any good free tool to kind of see bottlenecks in your code

Regards,
Chryso




Re: Common Language Runtime Enumeration, garbage collecting and allocation

nobugz

SortedList has O(log(n)) complexity, consider Hashtable or Dictionary<> for O(1) performance. I already gave you a free tool, find the rest of them with Google.





Re: Common Language Runtime Enumeration, garbage collecting and allocation

Chryso

Well could you explain the following

And regarding profilers I am trying to use ants but it takes way too much resources or makes my app crash on load Sad
Too bad about the sortedlist though Sad I thought it was O(1) in access Sad

Regards,
Chryso


EDIT: http://msdn2.microsoft.com/en-us/vcsharp/aa336818.aspx#profilers




Re: Common Language Runtime Enumeration, garbage collecting and allocation

nobugz

You've allocated about one Megabyte of objects. That's chump-change for a .NET app, it certainly wouldn't be a cause of a performance issue. The .NET heap allocator is blindingly fast. Performance problems don't start until you consume well over 100 MB. Again, a memory profiler doesn't tell you anything about code performance.





Re: Common Language Runtime Enumeration, garbage collecting and allocation

Chryso

The X86 GC is a generation GC and like really efficient... not the xbox one Sad and that is where we have some problems Sad
Since we can only profile on a PC and that from the xna tool to profile on xbox we see that the GC eats up way to much resources we are trying to find on a computer what can be the cause of a GC collect. Which means we have 1MB generated and we need to know where. And yes the GC are different, but we can try. I am willing to test any other way though Smile but that would be more pertaining to the xna forum and not this one I guess

But the question is why does it allocate so much enums .... is it because of the sortedlist
And to stay on the same topic I also have just plain matrices of float list:
List<float>[,] and they are showing in the heap. Normal or not float is a base type but not List... do arrays show in heap too... all question I do not really know where to look for an answer Sad


Regards,
Chryso




Re: Common Language Runtime Enumeration, garbage collecting and allocation

Greg Beech

If you're looking for a great profiler check out the JetBrains one. It can find both time and CPU bottlenecks. You can try it free for 14 days (or could the last time I checked) and even then it's not very expensive if you want to buy it.




Re: Common Language Runtime Enumeration, garbage collecting and allocation

Chryso

Hmm,
Thank you...

Next time I write a message on this board I ll say what I have running on my comp Sad

I do not have VS2005 so I cannot use the add in you nicely provided. And that I am not concerned about the windows GC but the xbox one Sad

Regards,
Chryso