Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / December 2004

Tip: Looking for answers? Try searching our database.

See memory allocated?  HashTable?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
jonhyland@hotmail.com - 16 Dec 2004 21:16 GMT
Does anyone know if there's a way to see how much memory a particular
object is using in .NET?

For example, suppose I have a HashTable or NameValueCollection and I
keep adding things to it.  I want to know the total number of bytes the
object is using.

Is there any way to do this?

Thanks in advance!
Morten Wennevik - 16 Dec 2004 21:51 GMT
Hi Jon Hyland,

The only way I can think of is using Marshal.SizeOf(object).

Signature

Happy Coding!
Morten Wennevik [C# MVP]

Imran Koradia - 16 Dec 2004 22:12 GMT
Just a point to note - Marshal.SizeOf will return the unmanaged size of the
object. The runtime adds overhead for each type so the managed size would be
slightly different.

That said, here's an excellent article in the december issue of the MSDN
magazine on memory usage and optimazations:
http://msdn.microsoft.com/msdnmag/issues/05/01/MemoryOptimization/default.aspx

According to the article, you could use performance counters and measure the
change in the heap memory when creating your objects to get a feel of the
size your objects are occupying. Also, you could use the CLR profiler (link
in the article for the download) to monitor memory usage.

hope that helps..
Imran.

> Does anyone know if there's a way to see how much memory a particular
> object is using in .NET?
[quoted text clipped - 6 lines]
>
> Thanks in advance!
Mr. Mountain - 17 Dec 2004 01:11 GMT
I have had excellent results using .NET Memory Profiler. I believe they have
a free trial.

> Does anyone know if there's a way to see how much memory a particular
> object is using in .NET?
[quoted text clipped - 6 lines]
>
> Thanks in advance!

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.