473,406 Members | 2,633 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Object Size in memory

How can I find the size of an object in memory?

Say a bitmap?

I took a bitmap and resized it and am storing in memory.
Would like to be able to see the amount of memory that object is taking.

How to???

Shane
Nov 20 '05 #1
7 2087
Hi Shane
You might want to use the CLR profiler for that; it is a tool that
is meant to profile the memory usage of .net programs and their objects
http://www.microsoft.com/downloads/d...052-D7F4-4AEB-
9B7A-94635BEEBDDA&displaylang=en

Mohamed Mahfouz
MEA Developer Support Center
ITworx on behalf of Microsoft EMEA GTSC

Nov 20 '05 #2
So there is no SIZEOF like in C++? or anything similar to get memory size
internally?

Thanks,

Shane

"Mohamoss" <mo************@egdsc.microsoft.com> wrote in message
news:Ox**************@cpmsftngxa10.phx.gbl...
Hi Shane
You might want to use the CLR profiler for that; it is a tool that
is meant to profile the memory usage of .net programs and their objects
http://www.microsoft.com/downloads/d...052-D7F4-4AEB- 9B7A-94635BEEBDDA&displaylang=en

Mohamed Mahfouz
MEA Developer Support Center
ITworx on behalf of Microsoft EMEA GTSC

Nov 20 '05 #3
Hi, SStory

See Marshal.SizeOf method.

HTH
Alex

"SStory" <Th*******@TAKEOUTTHISSPAMBUSTERsofthome.net> wrote in message
news:uk**************@TK2MSFTNGP12.phx.gbl...
So there is no SIZEOF like in C++? or anything similar to get memory size
internally?

Thanks,

Shane

"Mohamoss" <mo************@egdsc.microsoft.com> wrote in message
news:Ox**************@cpmsftngxa10.phx.gbl...
Hi Shane
You might want to use the CLR profiler for that; it is a tool that is meant to profile the memory usage of .net programs and their objects

http://www.microsoft.com/downloads/d...052-D7F4-4AEB-
9B7A-94635BEEBDDA&displaylang=en

Mohamed Mahfouz
MEA Developer Support Center
ITworx on behalf of Microsoft EMEA GTSC


Nov 20 '05 #4
* "AlexS" <sa***********@SPAMsympaticoPLEASE.ca> scripsit:
Hi, SStory

See Marshal.SizeOf method.


Or 'Len' for some types. But be sure you read the docs for both of them.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #5
doesn't seem to work for managed objects.
gave me an error when I tried that.

"AlexS" <sa***********@SPAMsympaticoPLEASE.ca> wrote in message
news:OX**************@tk2msftngp13.phx.gbl...
Hi, SStory

See Marshal.SizeOf method.

HTH
Alex

"SStory" <Th*******@TAKEOUTTHISSPAMBUSTERsofthome.net> wrote in message
news:uk**************@TK2MSFTNGP12.phx.gbl...
So there is no SIZEOF like in C++? or anything similar to get memory size
internally?

Thanks,

Shane

"Mohamoss" <mo************@egdsc.microsoft.com> wrote in message
news:Ox**************@cpmsftngxa10.phx.gbl...
Hi Shane
You might want to use the CLR profiler for that; it is a tool

that is meant to profile the memory usage of .net programs and their objects

http://www.microsoft.com/downloads/d...052-D7F4-4AEB-
9B7A-94635BEEBDDA&displaylang=en

Mohamed Mahfouz
MEA Developer Support Center
ITworx on behalf of Microsoft EMEA GTSC



Nov 20 '05 #6
Try this code
int i = 0;

Console.WriteLine("Int size: {0}", Marshal.SizeOf(i.GetType()));

HTH

Alex

"SStory" <Th*******@TAKEOUTTHISSPAMBUSTERsofthome.net> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
doesn't seem to work for managed objects.
gave me an error when I tried that.

"AlexS" <sa***********@SPAMsympaticoPLEASE.ca> wrote in message
news:OX**************@tk2msftngp13.phx.gbl...
Hi, SStory

See Marshal.SizeOf method.

HTH
Alex

"SStory" <Th*******@TAKEOUTTHISSPAMBUSTERsofthome.net> wrote in message
news:uk**************@TK2MSFTNGP12.phx.gbl...
So there is no SIZEOF like in C++? or anything similar to get memory size internally?

Thanks,

Shane

"Mohamoss" <mo************@egdsc.microsoft.com> wrote in message
news:Ox**************@cpmsftngxa10.phx.gbl...
> Hi Shane
> You might want to use the CLR profiler for that; it is a tool

that
> is meant to profile the memory usage of .net programs and their objects >

http://www.microsoft.com/downloads/d...052-D7F4-4AEB-
> 9B7A-94635BEEBDDA&displaylang=en
>
> Mohamed Mahfouz
> MEA Developer Support Center
> ITworx on behalf of Microsoft EMEA GTSC
>



Nov 20 '05 #7
It tells me that it can't do it. Something about no intellegent unmanaged
size can be calculated---this is a paraphrase of course.

Shane

"AlexS" <sa***********@SPAMsympaticoPLEASE.ca> wrote in message
news:On**************@TK2MSFTNGP10.phx.gbl...
Try this code
int i = 0;

Console.WriteLine("Int size: {0}", Marshal.SizeOf(i.GetType()));

HTH

Alex

"SStory" <Th*******@TAKEOUTTHISSPAMBUSTERsofthome.net> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
doesn't seem to work for managed objects.
gave me an error when I tried that.

"AlexS" <sa***********@SPAMsympaticoPLEASE.ca> wrote in message
news:OX**************@tk2msftngp13.phx.gbl...
Hi, SStory

See Marshal.SizeOf method.

HTH
Alex

"SStory" <Th*******@TAKEOUTTHISSPAMBUSTERsofthome.net> wrote in message news:uk**************@TK2MSFTNGP12.phx.gbl...
> So there is no SIZEOF like in C++? or anything similar to get memory

size
> internally?
>
> Thanks,
>
> Shane
>
> "Mohamoss" <mo************@egdsc.microsoft.com> wrote in message
> news:Ox**************@cpmsftngxa10.phx.gbl...
> > Hi Shane
> > You might want to use the CLR profiler for that; it is a tool that
> > is meant to profile the memory usage of .net programs and their

objects
> >
>

http://www.microsoft.com/downloads/d...052-D7F4-4AEB-
> > 9B7A-94635BEEBDDA&displaylang=en
> >
> > Mohamed Mahfouz
> > MEA Developer Support Center
> > ITworx on behalf of Microsoft EMEA GTSC
> >
>
>



Nov 20 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Richard | last post by:
Hi all, I am looking for some help on understanding the overhead associated with object creation in Java. I am writing an application where I have written a class to encapsulate some text...
16
by: cwizard | last post by:
I'm calling on a function from within this form, and there are values set but every time it gets called I get slammed with a run time error... document.frmKitAmount.txtTotalKitValue is null or not...
6
by: Virendra Verma | last post by:
This sounds weird, but I am looking for separate behaviors for destruction of a const and non-const object. I am trying to develop a smart/auto pointer class for writing objects to disk...
9
by: Andrew Au | last post by:
Dear all, I am trying to write a piece of software that use Object Oriented design and implement it with C, I did the following == In Object.h == typedef struct ObjectStructure* Object; ...
6
by: cameron | last post by:
I need to get the size of an objet in memory. I have tried: System.IO.MemoryStream m = new System.IO.MemoryStream(); System.Runtime.Serialization.Formatters.Binary.BinaryFormatter b = new...
5
by: Phil Jones | last post by:
Is there a way to determine the size (number of bytes) of an object? I figure this can be done by serializing the object to disk and measuring the file size - but I definately don't want to do...
8
by: al.cpwn | last post by:
Which sections of the 2003 standard should I study to understand the object model? I am looking to find information similar to that in Stanley B. Lippman's book, "Inside the C++ Object Model"
6
by: Scirious | last post by:
People, how can I know how big an object is? I mean, I have an object the collects data from a stream and when it grows to an especific size I need to create a new object to continue collecting the...
0
by: =?Utf-8?B?SkhhbGV5?= | last post by:
Our system is: IIS Server: dual Intel Xeon 2.80 GHz, 4 GB Ram Windows Server 2003 SP2 IIS 6.0 SQL Server: dual Intel Xeon 2.80 GHz, 4 GB Ram (separate server) Windows Server 2003 SP2 SQL...
23
by: tonytech08 | last post by:
What I like about the C++ object model: that the data portion of the class IS the object (dereferencing an object gets you the data of a POD object). What I don't like about the C++ object...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.