?
Solved

Memory Allocation with multiple instances of a Class

Posted on 2008-06-20
3
Medium Priority
?
408 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 500 total points
ID: 21833122
0
 

Author Closing Comment

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

Featured Post

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

Invest in your employees with these five simple steps to improve employee engagement and retention.
This post contains step-by-step instructions for setting up alerting in Percona Monitoring and Management (PMM) using Grafana.
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Suggested Courses

770 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