Solved

Memory Allocation with multiple instances of a Class

Posted on 2008-06-20
3
404 Views
Last Modified: 2013-12-17
Hi, Experts -
I have a question born more of curiousity than criticallty. Let's say that I create a class "Widget". In this class is a set of functions and routines necessary to process Widget. I then have a program that creates 1000 instances of Widget into a Collection of Widgets.

Does VB.NET allocate memory and run a full 1000 duplicates of the code? I assume that they run in the same process space as the program that created the collection, since they are not on different threads. Or does the code for the functions/routines somehow get shared by all 1000 instances of Widget?

Many thanks for your clarification!

LongDave
0
Comment
Question by:LongDave
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 41

Expert Comment

by:graye
ID: 21833117
Yes, they are all created separately and run in the same process space.   There *is* a way you can write a class that uses the "Shared" keyword... this allows you to actually have (at least a part) of the class instances that are shared amoung the 1000 copies.   However, the usefulness of the Shared keyword may not be that great depending on what your class does.
0
 
LVL 41

Accepted Solution

by:
graye earned 125 total points
ID: 21833122
0
 

Author Closing Comment

by:LongDave
ID: 31469234
Thanks, bud - points to you.
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A high-level exploration of how our ever-increasing access to information has changed the way we do our jobs.
Skype is a P2P (Peer to Peer) instant messaging and VOIP (Voice over IP) service – as well as a whole lot more.
The viewer will learn how to successfully create a multiboot device using the SARDU utility on Windows 7. Start the SARDU utility: Change the image directory to wherever you store your ISOs, this will prevent you from having 2 copies of an ISO wit…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

735 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question