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

Memory Allocation On The Heap For Reference Type

I want to declare the following

Dim BoolGrid(511,511) as Boolean

and

Dim Bitgrid As New BitArray(511*511)
How can I find out the size of memory allocated on the heap for each one ?

--
Best Regards - OHM

O_H_M{at}BTInternet{dot}com

Nov 20 '05 #1
6 1642
Well, the question was more on a general basis actually. For example, if my class contained 50 private value types of different ones like integer, double, float etc. How could I find out what the memory taken up my the actual object is on the heap.

Regards
--
Best Regards - OHM

O_H_M{at}BTInternet{dot}com

"Crirus" <Cr****@datagroup.ro> wrote in message news:Oe**************@TK2MSFTNGP12.phx.gbl...
Now I answer to you LOL

Boolean variables are stored as 16-bit (2-byte) numbers

BitArray need 1 byte for each 8 values

So I guess a bitArray(16) that hold 16 values is as large as 1 boolean.

Am I right?

--
Cheers,
Crirus

------------------------------
If work were a good thing, the boss would take it all from you

------------------------------

"One Handed Man [ OHM# ]" <O_H_M{at}BTInternet{dot}com> wrote in message news:u0**************@TK2MSFTNGP10.phx.gbl...
I want to declare the following

Dim BoolGrid(511,511) as Boolean

and

Dim Bitgrid As New BitArray(511*511)
How can I find out the size of memory allocated on the heap for each one ?

--
Best Regards - OHM

O_H_M{at}BTInternet{dot}com

Nov 20 '05 #2
I dont know what you find funny about my question. It is perfectly reasonable.

--
Best Regards - OHM

O_H_M{at}BTInternet{dot}com

"Crirus" <Cr****@datagroup.ro> wrote in message news:um**************@TK2MSFTNGP09.phx.gbl...
I dont suggest to add each fied's requirement...
LOL

--
Cheers,
Crirus

------------------------------
If work were a good thing, the boss would take it all from you

------------------------------

"One Handed Man [ OHM# ]" <O_H_M{at}BTInternet{dot}com> wrote in message news:OK*************@TK2MSFTNGP11.phx.gbl...
Well, the question was more on a general basis actually. For example, if my class contained 50 private value types of different ones like integer, double, float etc. How could I find out what the memory taken up my the actual object is on the heap.

Regards
--
Best Regards - OHM

O_H_M{at}BTInternet{dot}com

"Crirus" <Cr****@datagroup.ro> wrote in message news:Oe**************@TK2MSFTNGP12.phx.gbl...
Now I answer to you LOL

Boolean variables are stored as 16-bit (2-byte) numbers

BitArray need 1 byte for each 8 values

So I guess a bitArray(16) that hold 16 values is as large as 1 boolean.

Am I right?

--
Cheers,
Crirus

------------------------------
If work were a good thing, the boss would take it all from you

------------------------------

"One Handed Man [ OHM# ]" <O_H_M{at}BTInternet{dot}com> wrote in message news:u0**************@TK2MSFTNGP10.phx.gbl...
I want to declare the following

Dim BoolGrid(511,511) as Boolean

and

Dim Bitgrid As New BitArray(511*511)
How can I find out the size of memory allocated on the heap for each one ?

--
Best Regards - OHM

O_H_M{at}BTInternet{dot}com

Nov 20 '05 #3
* "One Handed Man [ OHM# ]" <O_H_M{at}BTInternet{dot}com> scripsit:
Well, the question was more on a general basis actually. For example, if my class contained 50 private value types of different
ones like integer, double, float etc. How could I find out what the memory taken up my the actual object is on the heap.


Memory Profiler:

<http://www.gotdotnet.com/Community/UserSamples/Details.aspx?SampleGuid=3254325d-a4aa-4bb3-aa86-c72d5104ec74>

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #4
Boolean variables are stored as 16-bit (2-byte) numbers


They are 1 byte actually. Any documentation that says 2 bytes are
remains from VB6.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Nov 20 '05 #5
Even so, a BitArray require a byte of memory for 8 boolean values so I guess
is better to use BitArray for lots of related booleans like my case is

--
Cheers,
Crirus

------------------------------
If work were a good thing, the boss would take it all from you

------------------------------

"Mattias Sjögren" <ma********************@mvps.org> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Boolean variables are stored as 16-bit (2-byte) numbers


They are 1 byte actually. Any documentation that says 2 bytes are
remains from VB6.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.

Nov 20 '05 #6
Look at CLR Profiler. Gives you all this information, and much more.

http://www.microsoft.com/downloads/d...displaylang=en

Aiax
"One Handed Man [ OHM# ]" <O_H_M{at}BTInternet{dot}com> wrote in message news:u0**************@TK2MSFTNGP10.phx.gbl...
I want to declare the following

Dim BoolGrid(511,511) as Boolean

and

Dim Bitgrid As New BitArray(511*511)
How can I find out the size of memory allocated on the heap for each one ?

--
Best Regards - OHM

O_H_M{at}BTInternet{dot}com

Nov 20 '05 #7

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

Similar topics

0
by: Andreas Suurkuusk | last post by:
Hi, I just noticed your post in the "C# memory problem: no end for our problem?" thread. In the post you implied that I do not how the garbage collector works and that I mislead people. Since...
2
by: mosfets | last post by:
Hi, I'm having a little trouble figuring out the difference in terms of memory allocation between: class person_info; class A { private:
9
by: Mike P | last post by:
I know everything about reference counting and making sure you don't have large objects lying around. I have also profiled my app with multiple tools. I know about the fact GC collects memory but...
4
by: xixi | last post by:
i have a very serious memory problem, we have db2 udb v8.1 load on a HP titanium machine with 4 G memory, it is 64bit machine, currently on DB2 instance , i have three databases, but only one is...
6
by: Michael Isaacs | last post by:
Regarding use of enum's, I am wondering what the cost of memory is when creating the enumeration on the calling side, and then using it on the function/method side. See example below. If I...
2
by: Saber | last post by:
Public Class User Private _id, _P, _L, _R As Integer Private _balance As Int64 Private _name, _family, _tel1, _tel2, _mobile, _city, _accountNumber As String Private _password, _email,...
3
by: toton | last post by:
Operator overloading has a sort syntax rather than member function call for stack based memory allocation. like complex<int> c1,c2,c3; c3= c1+c2; How the same can be applied to heap based...
18
by: happyvalley | last post by:
Hi, basically, the test function get a char pointer, and assigned a string to it. then the string is passed back by the call-by-reference mechanism. in test(), I reallocate some memory for the...
81
by: Peter Olcott | last post by:
It looks like System::Collections::Generic.List throws and OUT_OF_MEMORY exception whenever memory allocated exceeds 256 MB. I have 1024 MB on my system so I am not even out of physical RAM, much...
2
by: Andy Baker | last post by:
I have recently written a .NET wrapper for a C++ DLL file and it seems to be working well, but I do have some concerns about memory. From my limited C programming experience (college 15+ years...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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,...

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.