V
Vanessa
Hi guys,
First, I'm a newbie
I've been trying to create an application using C#. The application has 2
classes.
Class A and class B. Class A will read a file and store the data in a byte
array.
Then based on user action, class A will create class B and pass the byte
array as constructor parameter.
class A:
{
...
byte[] data;
...
createB(data);
...
}
class B:
{
public B(byte[] data)
{
...
DoProcess(data);
...
}
}
The problem is every time the class B is created, it seems to create a new
instance of byte array, which then takes memory resource.
For example, if the byte array is 10MB in size and I have 5 class B created,
it takes, at least, 50MB of memory ( as I can see in the task manager ).
Hence, the application becomes memory hungry.
How can I make the byte array as 'static' reference so class B won't need to
create a new instance of it every time it is created?
Thanks.
Note: the real application is a tabcontrol based winform application. The
byte array will be needed for each tab page to do some processing.
Class A is the main form, and Class B is class that extends TabPage.
First, I'm a newbie

I've been trying to create an application using C#. The application has 2
classes.
Class A and class B. Class A will read a file and store the data in a byte
array.
Then based on user action, class A will create class B and pass the byte
array as constructor parameter.
class A:
{
...
byte[] data;
...
createB(data);
...
}
class B:
{
public B(byte[] data)
{
...
DoProcess(data);
...
}
}
The problem is every time the class B is created, it seems to create a new
instance of byte array, which then takes memory resource.
For example, if the byte array is 10MB in size and I have 5 class B created,
it takes, at least, 50MB of memory ( as I can see in the task manager ).
Hence, the application becomes memory hungry.
How can I make the byte array as 'static' reference so class B won't need to
create a new instance of it every time it is created?
Thanks.
Note: the real application is a tabcontrol based winform application. The
byte array will be needed for each tab page to do some processing.
Class A is the main form, and Class B is class that extends TabPage.