What are the ramifications if I were to instantiate an object tens of
thousands of times and add them to an array? Or hundreds of thousands of
times? Do you know if the act of instantiating a class takes a lot of
storage or other resources? Would it be a severe performance penalty?
From the .Net help doc:
You declare and use arrays of an object type just as you would declare and
use an array of any data type. The members of this array can be retrieved by
their index, and can be manipulated as any object of this type would be.
Arrays also have built-in functionality for searching and sorting that can
be accessed through the array variable. For more information on these
methods, see Array Class.
To create an array of objects
Declare the array as shown in the sample code below. Because arrays are
zero-based, they contain one member more than the upper bound you declare.
Dim x(10) As Widget ' Contains 11 members, from x(0) to x(10).
Instantiate each member of the array, or assign each member a reference to
an already existing object. An example of each approach is shown below:
' Instantiates each member of an array by using a loop.
Dim q As Integer
For q = 0 to 10
x(q) = New Widget()
Next
' Assigns a member of an array a reference to an existing object.
Dim myWidget As New Widget()
x(0) = myWidget
x(1) = myWidget
Note that you can assign the different members of the array references to
the same object. 6 1593
Dont forget you are storing references to these objects in the array. The
main penalty is use of memory but if there is enough of it then you should
be ok. I suppose it might give the Garbage collector something to chew on.
I would suggest you write a loop to generate it and see what happens.
--
OHM ( Terry Burns ) * Use the following to email me *
Dim ch() As Char = "ufssz/cvsotAhsfbuTpmvujpotXjui/OFU".ToCharArray()
For i As Int32 = 0 To ch.Length - 1
ch(i) = Convert.ToChar(Convert.ToInt16(ch(i)) - 1)
Next
Process.Start("mailto:" & New String(ch))
--
"Gary Frank" <ga**************@REMOVEsbcglobal.net> wrote in message
news:bD*****************@newssvr11.news.prodigy.co m... What are the ramifications if I were to instantiate an object tens of thousands of times and add them to an array? Or hundreds of thousands of times? Do you know if the act of instantiating a class takes a lot of storage or other resources? Would it be a severe performance penalty?
From the .Net help doc:
You declare and use arrays of an object type just as you would declare and use an array of any data type. The members of this array can be retrieved by their index, and can be manipulated as any object of this type would be. Arrays also have built-in functionality for searching and sorting that can be accessed through the array variable. For more information on these methods, see Array Class. To create an array of objects Declare the array as shown in the sample code below. Because arrays are zero-based, they contain one member more than the upper bound you declare.
Dim x(10) As Widget ' Contains 11 members, from x(0) to x(10).
Instantiate each member of the array, or assign each member a reference to an already existing object. An example of each approach is shown below:
' Instantiates each member of an array by using a loop.
Dim q As Integer
For q = 0 to 10
x(q) = New Widget()
Next ' Assigns a member of an array a reference to an existing object.
Dim myWidget As New Widget()
x(0) = myWidget
x(1) = myWidget
Note that you can assign the different members of the array references to the same object.
Hi there,
I wouldn't worry if I were you, I made a 3D engine which opened obj
files, this instantiated thousands upon thousands of objects. The only
speed pentalty was drawing them using GDI+. But one thing you might find
benificial is making typed collections, this way you can have the benefit of
a collection object rather that having to handle arrays on your own.
You can check out my 3D engine, it's not amazing trust me, but it is
capabale of creating allot of objects! http://www.members.lycos.co.uk/nickpatemanpwp/
Go to "My own software > Starfield +", you'll notice that the engine is
called crapEngine, but it isn't that bad honest! :-)
Nick.
"Gary Frank" <ga**************@REMOVEsbcglobal.net> wrote in message
news:bD*****************@newssvr11.news.prodigy.co m... What are the ramifications if I were to instantiate an object tens of thousands of times and add them to an array? Or hundreds of thousands of times? Do you know if the act of instantiating a class takes a lot of storage or other resources? Would it be a severe performance penalty?
From the .Net help doc:
You declare and use arrays of an object type just as you would declare and use an array of any data type. The members of this array can be retrieved by their index, and can be manipulated as any object of this type would be. Arrays also have built-in functionality for searching and sorting that can be accessed through the array variable. For more information on these methods, see Array Class. To create an array of objects Declare the array as shown in the sample code below. Because arrays are zero-based, they contain one member more than the upper bound you declare.
Dim x(10) As Widget ' Contains 11 members, from x(0) to x(10).
Instantiate each member of the array, or assign each member a reference to an already existing object. An example of each approach is shown below:
' Instantiates each member of an array by using a loop.
Dim q As Integer
For q = 0 to 10
x(q) = New Widget()
Next ' Assigns a member of an array a reference to an existing object.
Dim myWidget As New Widget()
x(0) = myWidget
x(1) = myWidget
Note that you can assign the different members of the array references to the same object.
Clever spam filter!
"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in message
news:Os**************@TK2MSFTNGP15.phx.gbl... Dont forget you are storing references to these objects in the array. The main penalty is use of memory but if there is enough of it then you should be ok. I suppose it might give the Garbage collector something to chew on. I would suggest you write a loop to generate it and see what happens.
-- OHM ( Terry Burns ) * Use the following to email me *
Dim ch() As Char = "ufssz/cvsotAhsfbuTpmvujpotXjui/OFU".ToCharArray() For i As Int32 = 0 To ch.Length - 1 ch(i) = Convert.ToChar(Convert.ToInt16(ch(i)) - 1) Next Process.Start("mailto:" & New String(ch)) --
"Gary Frank" <ga**************@REMOVEsbcglobal.net> wrote in message news:bD*****************@newssvr11.news.prodigy.co m... What are the ramifications if I were to instantiate an object tens of thousands of times and add them to an array? Or hundreds of thousands of times? Do you know if the act of instantiating a class takes a lot of storage or other resources? Would it be a severe performance penalty?
From the .Net help doc:
You declare and use arrays of an object type just as you would declare and use an array of any data type. The members of this array can be retrieved by their index, and can be manipulated as any object of this type would be. Arrays also have built-in functionality for searching and sorting that can be accessed through the array variable. For more information on these methods, see Array Class. To create an array of objects Declare the array as shown in the sample code below. Because arrays are zero-based, they contain one member more than the upper bound you declare.
Dim x(10) As Widget ' Contains 11 members, from x(0) to x(10).
Instantiate each member of the array, or assign each member a reference to an already existing object. An example of each approach is shown below:
' Instantiates each member of an array by using a loop.
Dim q As Integer
For q = 0 to 10
x(q) = New Widget()
Next ' Assigns a member of an array a reference to an existing object.
Dim myWidget As New Widget()
x(0) = myWidget
x(1) = myWidget
Note that you can assign the different members of the array references to the same object.
I read you note and was curious as to how to make a typed collection? Do you
have any code examples or references?
"Nak" wrote: Hi there,
I wouldn't worry if I were you, I made a 3D engine which opened obj files, this instantiated thousands upon thousands of objects. The only speed pentalty was drawing them using GDI+. But one thing you might find benificial is making typed collections, this way you can have the benefit of a collection object rather that having to handle arrays on your own.
You can check out my 3D engine, it's not amazing trust me, but it is capabale of creating allot of objects!
http://www.members.lycos.co.uk/nickpatemanpwp/
Go to "My own software > Starfield +", you'll notice that the engine is called crapEngine, but it isn't that bad honest! :-)
Nick.
"Gary Frank" <ga**************@REMOVEsbcglobal.net> wrote in message news:bD*****************@newssvr11.news.prodigy.co m... What are the ramifications if I were to instantiate an object tens of thousands of times and add them to an array? Or hundreds of thousands of times? Do you know if the act of instantiating a class takes a lot of storage or other resources? Would it be a severe performance penalty?
From the .Net help doc:
You declare and use arrays of an object type just as you would declare and use an array of any data type. The members of this array can be retrieved by their index, and can be manipulated as any object of this type would be. Arrays also have built-in functionality for searching and sorting that can be accessed through the array variable. For more information on these methods, see Array Class. To create an array of objects Declare the array as shown in the sample code below. Because arrays are zero-based, they contain one member more than the upper bound you declare.
Dim x(10) As Widget ' Contains 11 members, from x(0) to x(10).
Instantiate each member of the array, or assign each member a reference to an already existing object. An example of each approach is shown below:
' Instantiates each member of an array by using a loop.
Dim q As Integer
For q = 0 to 10
x(q) = New Widget()
Next ' Assigns a member of an array a reference to an existing object.
Dim myWidget As New Widget()
x(0) = myWidget
x(1) = myWidget
Note that you can assign the different members of the array references to the same object.
"Gary Frank" <ga**************@REMOVEsbcglobal.net> wrote What are the ramifications if I were to instantiate an object tens of thousands of times and add them to an array? Or hundreds of thousands of times? Do you know if the act of instantiating a class takes a lot of storage or other resources? Would it be a severe performance penalty?
Creating new objects require memory, where the amount required depends
on the size of the object you are creating.. Under normal conditions the CLR
(runtime) is looking right at a large free memory area so allocations go real
quick, until you run out of memory.
HTH
LFS
:)
--
OHM ( Terry Burns ) * Use the following to email me *
Dim ch() As Char = "ufssz/cvsotAhsfbuTpmvujpotXjui/OFU".ToCharArray()
For i As Int32 = 0 To ch.Length - 1
ch(i) = Convert.ToChar(Convert.ToInt16(ch(i)) - 1)
Next
Process.Start("mailto:" & New String(ch))
--
"Jared" <as***********@nospam.com> wrote in message
news:10*************@corp.supernews.com... Clever spam filter!
"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in message news:Os**************@TK2MSFTNGP15.phx.gbl... Dont forget you are storing references to these objects in the array. The main penalty is use of memory but if there is enough of it then you should be ok. I suppose it might give the Garbage collector something to chew on. I would suggest you write a loop to generate it and see what happens.
-- OHM ( Terry Burns ) * Use the following to email me *
Dim ch() As Char = "ufssz/cvsotAhsfbuTpmvujpotXjui/OFU".ToCharArray() For i As Int32 = 0 To ch.Length - 1 ch(i) = Convert.ToChar(Convert.ToInt16(ch(i)) - 1) Next Process.Start("mailto:" & New String(ch)) --
"Gary Frank" <ga**************@REMOVEsbcglobal.net> wrote in message news:bD*****************@newssvr11.news.prodigy.co m... What are the ramifications if I were to instantiate an object tens of thousands of times and add them to an array? Or hundreds of thousands of times? Do you know if the act of instantiating a class takes a lot of storage or other resources? Would it be a severe performance penalty?
From the .Net help doc:
You declare and use arrays of an object type just as you would declare and use an array of any data type. The members of this array can be retrieved by their index, and can be manipulated as any object of this type would be. Arrays also have built-in functionality for searching and sorting that can be accessed through the array variable. For more information on these methods, see Array Class. To create an array of objects Declare the array as shown in the sample code below. Because arrays are zero-based, they contain one member more than the upper bound you declare.
Dim x(10) As Widget ' Contains 11 members, from x(0) to x(10).
Instantiate each member of the array, or assign each member a reference to an already existing object. An example of each approach is shown below:
' Instantiates each member of an array by using a loop.
Dim q As Integer
For q = 0 to 10
x(q) = New Widget()
Next ' Assigns a member of an array a reference to an existing object.
Dim myWidget As New Widget()
x(0) = myWidget
x(1) = myWidget
Note that you can assign the different members of the array references to the same object.
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Roberto Gerola |
last post by:
Hi,
I've developed for our PHP projects a little
object persistence library.
Tha main goal of the library is to speed up
the management of the data stored in a db.
It is based on the concept...
|
by: Peter Bär |
last post by:
A Question to the C#/.Net Gods of this forum:
are there performance penalties when i compile (C#, FW1.1, ASP.NET,
Studio2003) a central baseclass in a different assembly than all the
derived...
|
by: Peter Bär |
last post by:
A Question to the C#/.Net Gods of this forum:
are there performance penalties when i compile (C#, FW1.1, ASP.NET,
Studio2003) a central baseclass in a different assembly than all the
derived...
|
by: HarishP |
last post by:
Hi,
How to avoid instantiating the class more than 10 times
Harish.P
Sr. Software Engineer
Comat Technologies Pvt. Ltd.,
Bangalore
Email: harish.p@comat.com
|
by: Chris Spencer |
last post by:
Before I get too carried away with something that's probably
unnecessary, please allow me to throw around some ideas. I've been
looking for a method of transparent, scalable, and human-readable...
|
by: Kevin Stone |
last post by:
Hi,
I currently have a piece of JavaScript which swaps the on-screen image
between two different versions, and I use:
document.images.src = something
and change the src each time. However,...
|
by: zouyongbin |
last post by:
Stanley B Lippman in his "C++ Primer" that a definition like this
should not appear in a header file:
int ix;
The inclusion of any of these definitions in two or more files of the
same...
|
by: Berteun Damman |
last post by:
Hello,
I have programmed some python script that loads a graph (the
mathemical one with vertices and edges) into memory, does some
transformations on it, and then tries to find shortest paths in...
|
by: Aaron Watters |
last post by:
Poking around I discovered somewhere someone saying that
Python gc adds a 4-7% speed penalty.
So since I was pretty sure I was not creating
reference cycles in nucular I tried running the tests...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM)
The start time is equivalent to 19:00 (7PM) in Central...
|
by: giovanniandrean |
last post by:
The energy model is structured as follows and uses excel sheets to give input data:
1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
|
by: NeoPa |
last post by:
Hello everyone.
I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report).
I know it can be done by selecting :...
|
by: Teri B |
last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course.
0ne-to-many. One course many roles.
Then I created a report based on the Course form and...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM)
Please note that the UK and Europe revert to winter time on...
|
by: nia12 |
last post by:
Hi there,
I am very new to Access so apologies if any of this is obvious/not clear.
I am creating a data collection tool for health care employees to complete. It consists of a number of...
|
by: NeoPa |
last post by:
Introduction
For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
|
by: isladogs |
last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, Mike...
|
by: GKJR |
last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...
| |