G
Gregory Gadow
In a VB.Net 2.0 project, I have a WizardClass that contains a List (of
RuleClass). Each rule needs access to variables within it's parent
wizard, so the constructor for RuleClass is New (ByVal Wizard as
WizardClass). Each rule then has a property Private Wiz as WizardClass,
which is set in Sub New with Wiz = Wizard. Currently there is only one
Wizard in the project but there might be more in the future to handle
different rulesets.
My understanding is that, with this, each instance of RuleClass has its
own isolated and independent copy of WizardClass, which would take up a
huge amount of memory if there are a lot of rules. This is part of a
service, so the memory would be permanently used. Is this actually the
case? If so, any suggestions on how to prevent this memory use?
I am thinking that I can declare each instance of WizardClass to be
Shared, so in the service module:
Private Shared Wizzie1 as WizardClass
Private Shared Wizzie2 as WizardClass
would create independent instances of WizardClass and each time Wizzie1
or Wizzie2 appear on the right of an = a pointer to the instance would
be generated rather than a copy. So in the LoadRuleset method of
WizardClass
mRulesList.Add(New RuleClass(Me))
would create only a pointer to the shared parent wizard rather than a
complete copy of the wizard object. Will this do what I think it will?
Will this happen automatically when the project is compiled and
(hopefully) optimized? Or am I barking up the wrong tree entirely?
Thanks in advance for any help.
--
Gregory Gadow
(e-mail address removed)
http://www.serv.net/~techbear
"[W]e have never held that moral disapproval, without any other asserted
state interest, is a sufficient rationale under the Equal Protection
Clause to justify a law that discriminates among groups of persons."
- Sandra Day O`Conner, _Lawrence v Texas_
http://caselaw.lp.findlaw.com/scripts/getcase.pl?court=us&vol=000&invol=02-102
RuleClass). Each rule needs access to variables within it's parent
wizard, so the constructor for RuleClass is New (ByVal Wizard as
WizardClass). Each rule then has a property Private Wiz as WizardClass,
which is set in Sub New with Wiz = Wizard. Currently there is only one
Wizard in the project but there might be more in the future to handle
different rulesets.
My understanding is that, with this, each instance of RuleClass has its
own isolated and independent copy of WizardClass, which would take up a
huge amount of memory if there are a lot of rules. This is part of a
service, so the memory would be permanently used. Is this actually the
case? If so, any suggestions on how to prevent this memory use?
I am thinking that I can declare each instance of WizardClass to be
Shared, so in the service module:
Private Shared Wizzie1 as WizardClass
Private Shared Wizzie2 as WizardClass
would create independent instances of WizardClass and each time Wizzie1
or Wizzie2 appear on the right of an = a pointer to the instance would
be generated rather than a copy. So in the LoadRuleset method of
WizardClass
mRulesList.Add(New RuleClass(Me))
would create only a pointer to the shared parent wizard rather than a
complete copy of the wizard object. Will this do what I think it will?
Will this happen automatically when the project is compiled and
(hopefully) optimized? Or am I barking up the wrong tree entirely?
Thanks in advance for any help.
--
Gregory Gadow
(e-mail address removed)
http://www.serv.net/~techbear
"[W]e have never held that moral disapproval, without any other asserted
state interest, is a sufficient rationale under the Equal Protection
Clause to justify a law that discriminates among groups of persons."
- Sandra Day O`Conner, _Lawrence v Texas_
http://caselaw.lp.findlaw.com/scripts/getcase.pl?court=us&vol=000&invol=02-102