Are .NET applications a natural amount of memory?

I started writing a great C # application for the first time in my life. I wrote a sample module to test the idea of ​​my software. This module contained dozens of C # dictionaries and lists of objects, each of which had several elements and properties.

I was shocked that after initializing the main objects, about 40 MB of RAM is ultimately used.

I tested and found out that after the initialization of the object more than 30 MB is allocated, but I got the impression that, taking into account the size of my objects, it was necessary to consume no more than several hundred kilobytes.

Am I doing something wrong or is .NET naturally more memory intensive compared to native code applications?

+5
source share
8 answers

Using task manager to view your memory usage is likely to be terribly inaccurate.

Instead, grab the proper memory profiling tool ( dotTrace is very good and has a 10-day trial) and take the time to see your actual memory consumption.

Views I've seen in my own code include

  • Underestimate how much memory I use (not counting individual objects properly, not allowing lists to have "spare" capacity)
  • Saving references to temporary objects that I do not need.
  • Do not allow temporary objects created during operation that have not yet been garbage collected.
  • - , ​​ ( ),
  • ( ; .NET , ).
+7

, ? , .NET , , , , , .

, MSDN.

+12

, , , , , , , , #, 100 000 . .

, # ++, .

, 40 . - 10-14Mb . , , ram, , , (2.0).

+5

, , .

.

+2

.Net - , , , ++. , . - , " ", ++ , .

+2

, , , .. , , / . , ( ), 38 .

+2

, . - , . , - .NET. ,.NET CLR/GC , , .

( ), , , Process.MaxWorkingSet 0. SetProcessWorkingSetSize Win32, , . , , . , GC/CLR, - . GC .

, , CLR, dotTrace ( ), Ants Profiler (, , ). CLRProfiler , , .

0

, , , 340 . ( c12MB- 32-, yikes Steve!) [ , 8 +, ] System.Object runtime @Sun.com..

/, . , , 10 .NET, , C64. , WPF Silverlight c100MB .

( downvote)

-8
source

All Articles