By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,640 Members | 1,363 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,640 IT Pros & Developers. It's quick & easy.

Memory Allocation On The Heap For Reference Type

P: n/a
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
Share this Question
Share on Google+
6 Replies


P: n/a
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

P: n/a
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

P: n/a
* "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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.