473,387 Members | 1,572 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,387 software developers and data experts.

determining size of object

Hi all

is there as way i can tell the amount of memory my object takes. for example
if i have a collection of employee object say of 20, how much memory do they
take e.g. 500kb.

thank you.
Jan 22 '08 #1
6 1288
"Anthony Sox" <to*****@yahoo.comschrieb:
is there as way i can tell the amount of memory my object takes. for
example
if i have a collection of employee object say of 20, how much memory do
they
take e.g. 500kb.
No (there is no method to do that in the .NET Framework).

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Jan 22 '08 #2
On Jan 22, 4:05*pm, "Anthony Sox" <tony...@yahoo.comwrote:
Hi all

is there as way i can tell the amount of memory my object takes. for example
if i have a collection of employee object say of 20, how much memory do they
take e.g. 500kb.

thank you.
There isn't. But you can try the memory usage with testing with small
increments by putting more objects. Then you'll get a formula for
yourself, that may make easier to estimate memory usage at the end of
software.
Jan 22 '08 #3
"Herfried K. Wagner [MVP]" <hi***************@gmx.atwrote in
news:u2**************@TK2MSFTNGP04.phx.gbl:
"Anthony Sox" <to*****@yahoo.comschrieb:
>is there as way i can tell the amount of memory my object takes. for
example
if i have a collection of employee object say of 20, how much memory do
they
take e.g. 500kb.

No (there is no method to do that in the .NET Framework).
..NET's profiling API gives you this sort of information ... however it's
not that easy to use.

http://msdn.microsoft.com/msdnmag/is...ETProfilerAPI/

There are third party tools built upon this API which let you inspect your
application and check for memory usage and other details.

--
sp**********@rogers.com (Do not e-mail)
Jan 22 '08 #4
On Jan 22, 6:56*pm, Spam Catcher <spamhoney...@rogers.comwrote:
"Herfried K. Wagner [MVP]" <hirf-spam-me-h...@gmx.atwrote innews:u2**************@TK2MSFTNGP04.phx.gbl:
"Anthony Sox" <tony...@yahoo.comschrieb:
is there as way i can tell the amount of memory my object takes. for
example
if i have a collection of employee object say of 20, how much memory do
they
take e.g. 500kb.
No (there is no method to do that in the .NET Framework).

.NET's profiling API gives you this sort of information ... however it's
not that easy to use.

http://msdn.microsoft.com/msdnmag/is...ETProfilerAPI/

There are third party tools built upon this API which let you inspect your
application and check for memory usage and other details.

--
spamhoney...@rogers.com (Do not e-mail)
Also here is an shareware tool:
http://memprofiler.com/
Jan 22 '08 #5
"Anthony Sox" <to*****@yahoo.comwrote in message
news:Ob**************@TK2MSFTNGP02.phx.gbl...
Hi all

is there as way i can tell the amount of memory my object takes. for
example
if i have a collection of employee object say of 20, how much memory do
they
take e.g. 500kb.
..NET deliberately makes it extremely difficult to determine how much memory
an object actually consumes because the information is architectural and you
can't go messing about with the .NET architecture.

That said, there are at least two ways out of the near predicament.

1. Spend a few weeks mucking about with the CopyMemory API, allocating
objects to managed and unmanaged memory, interop object marshalling and
pointer to structure manipulations... and getting nowhere fast.

2. State the general structure of the objects and the purpose of needing to
know how much memory each one object consumes.

If you take option 2 then it can be determined if an approximation might be
sufficient, and if that is the case then there are any number of ways to
skin your particular cat.
Jan 22 '08 #6
Hi Anthony,

For simply types you can use Marshal.SizeOf, but for any complex types you
will need to use a managed profiler.
"Anthony Sox" <to*****@yahoo.comwrote in message
news:Ob**************@TK2MSFTNGP02.phx.gbl...
Hi all

is there as way i can tell the amount of memory my object takes. for
example
if i have a collection of employee object say of 20, how much memory do
they
take e.g. 500kb.

thank you.

Jan 23 '08 #7

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

Similar topics

2
by: Luca | last post by:
I have the following problem: I'm developing a system where there are some processes that communicate each other via message queues; the message one process can send to another process is as...
2
by: Phil Galey | last post by:
In VB.NET I find the IO object very handy in replacing most of the functionality of the FileSystemObject. One exception, however, is in determining the size of a file. How can you determine the...
12
by: Raja | last post by:
How to know the buffer size and increase buffer size in c++.
4
by: Jozef | last post by:
Hello, I'd like to determine the size of a file via a URL. I'm not even sure how to do this on the local machine, let alone a URL. Any help would be greatly appreciated. Thanks!
1
by: Rhy Mednick | last post by:
I'm creating a custom control (inherited from UserControl) that is displayed by other controls on the form. I would like for the control to disappear when the user clicks outside my control the...
3
by: Michael Geier | last post by:
Hello, suppose the following structure: __gc struct dfheader { int var1; int var2; unsigned var3; };
1
by: CES | last post by:
I'm looking for a JavaScript/.net replacement for Netscape's window.outerWidth that will work in IE and was wondering is their a way of determining if the search/history/favorites/etc. sidebar is...
2
by: Phil Galey | last post by:
Using the following, you can determine the size of a file: Dim fi As New IO.FileInfo(<Path to file>) MsgBox(fi.Length) .... but what about the size of a directory? The IO.DirectoryInfo object...
19
by: catmansa | last post by:
Is there anyway to determine the present pixel height & width size of a open browser window? :)
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...

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.