473,325 Members | 2,774 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,325 software developers and data experts.

Structure memory usage?

Hi,

I need help with a couple of questions, I have create and structure like:
Structure byteArray
Public byteA() As Byte

End Structure

Public ptrArray() As byteArray

I have redim ptrArray(1000000) and the memory usage in Windows Task Manager
shows an increase of 4MB bytes that seems OK.

Then I have done

for intI=1 to 1000000

Redim ptrArray(intI).byteA(1)

next intI

And now the memory in task manager shows and increase of almost 16 MB,
instead of 1MB.

QUESTIONS:

1) It seems that an structure increase the memory usage (I suppose it create
internal variables). Is there any other way that I can have an "Array of
Arrays" that can be dinamically increase without the memory overcost of
using a structure?.

2) Is ther any way (not Windows Task Manager) to know how much memory a
variable, or structure is using in vb.net?.

Thanks,

James

Dec 7 '05 #1
2 1931
"James" <in**@pricetech.es> schrieb
Hi,

I need help with a couple of questions, I have create and structure
like:
Structure byteArray
Public byteA() As Byte

End Structure

Public ptrArray() As byteArray

I have redim ptrArray(1000000) and the memory usage in Windows Task
Manager
shows an increase of 4MB bytes that seems OK.

Then I have done

for intI=1 to 1000000

Redim ptrArray(intI).byteA(1)

next intI

And now the memory in task manager shows and increase of almost 16
MB,
instead of 1MB.
You probably mean 2 MB because arrays are zero-based, and an upper bound of
1 creates the items 0 and 1.
QUESTIONS:

1) It seems that an structure increase the memory usage (I suppose
it create
internal variables). Is there any other way that I can have an
"Array of
Arrays" that can be dinamically increase without the memory overcost
of
using a structure?.
I don't know if it solves the memory issue, but and array of arrays can be
declared this way:

Public ptrArray()() As byte

This is an array of byte-arrays.

Public ptrArray(999999)() As byte

This is an array that can point to 1,000,000 byte arrays. Each of the 1 mio.
items is still Nothing.

Redim ptrArray(0)(99)

Now Item 0 points to an array of 100 bytes.

2) Is ther any way (not Windows Task Manager) to know how much memory a
variable, or structure is using in vb.net?.


I have no reliable answer to this. I can only point to

VB language reference -> data types -> data type summary.

There are few words about the memory consumption of arrays - maybe this
helps. Using that information: 1,000,000 * (12 + 8 + 2) = ~22 MB. But as I
said, I can not say this for sure, above all because the automatic memory
management is a "black box". Maybe you can ask this in the
microsoft.public.dotnet.framework.clr group because it is not really VB.Net
related.
Armin

Dec 7 '05 #2
"James" <in**@pricetech.es> schrieb:
2) Is ther any way (not Windows Task Manager) to know how much memory a
variable, or structure is using in vb.net?.


In addition to the other replies:

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

CLR Profiler (v2.0)
<URL:http://www.microsoft.com/downloads/details.aspx?FamilyId=86CE6052-D7F4-4AEB-9B7A-94635BEEBDDA&displaylang=en>

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

Dec 7 '05 #3

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

Similar topics

2
by: tomvr | last post by:
Hello I have noticed some 'weird' memory usage in a vb.net windows app The situation is as follows I have an app (heavy on images) with 2 forms (actually there are more forms and on starting...
6
by: Tom | last post by:
We have a VERY simple .NET C# Form Application, that has about a 23MB Memory Footprint. It starts a window runs a process and does a regular expression. I have done a GC.Collect to make sure that,...
3
by: Ian Taite | last post by:
Hello, I'm exploring why one of my C# .NET apps has "high" memory usage, and whether I can reduce the memory usage. I have an app that wakes up and processes text files into a database...
21
by: simon | last post by:
From my previous post... If I have a structure, struct sFileData { char*sSomeString1; char*sSomeString2; int iSomeNum1; int iSomeNum2;
26
by: Brett | last post by:
I have created a structure with five fields. I then create an array of this type of structure and place the structure into an array element. Say index one. I want to assign a value to field3 of...
3
by: zhphust | last post by:
I want to convert a object of a managed class to a unmanaged structure that has the same member with that managed class. Can anybody tell me how i can do it? Thanks in advance. -- zhphust...
6
by: James | last post by:
I am using vb.net and need to keep in memory a large data structure, so I am looking for the best option. And after several test I am pretty confused. So I will be grateful if anyone can help me. ...
8
by: SP | last post by:
The following code crashes after I add the two nested FOR loops at the end, I am starting to learn about pointers and would like to understand what I'm doing wrong. I think the problem is the way...
1
by: Jean-Paul Calderone | last post by:
On Tue, 22 Apr 2008 14:54:37 -0700 (PDT), yzghan@gmail.com wrote: The test doesn't demonstrate any leaks. It does demonstrate that memory usage can remain at or near peak memory usage even after...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.