Am I right when i say this?

Cheetah

Well-known member
Joined
Oct 12, 2006
Messages
232
Programming Experience
Beginner
Hi there,

If I load a variable into an image like this:

Code:
Dim img as Image = Image.FromFile("Path_to_file")
and then add it to a list like this:

Code:
Dim imgList as new list(of image)

imgList.Add(img)
...I have two instances of the image loaded into the memory and not one?

Thanks.
 

ImDaFrEaK

Well-known member
Joined
Jan 7, 2006
Messages
416
Location
California
Programming Experience
5-10
This all depends on the type of Object you are using. When the object is referenced then all variables are pointing to the same location in memory if the Object is not referenced then it is not. The most luck you may have is to share the same Object from a memory pool. Its all a little complicated but here is something to look at. Structures are not referenced while most all other Objects are. So if you were to put something like Integers into that List then yes you would have 2 objects in memory but since you are using an Image Object then you are referencing the same object. Does this make since? I hope it helps you in the future to understand this somewhat. It can definately help you in situations when you yourself are creating Objects and need to know when to use a structure or class ect...
 
Top Bottom