Concerns about Type generation

H

Hans Kesting

Hi all,

I'm developing an application (asp.net) where a site-manager can enter
a bunch of formulas. The users supply data for those formulas and cause
them to be evaluated.

The evaluation works by generating a Type, creating an instance of it
and executing specific methods. This works.

I am concerned about possible memory leaks: an *instance* gets
garbage-collected when it is not in use anymore, but what about a
*Type*? In the current system there will not be many changes, but later
(in other applications that want to use the same formula-system) there
might be.
And each change will need a new Type. And if I understand correctly,
that definition will remain in memory until the application is
recycled.

Any ideas? Probably someone has already figured it out and put it on
some website?

Note: I am not interested in dynamic *invoke* of an existing class,
it's dynamically *creating* that class.

Hans Kesting
 
A

Alberto Poblacion

Hans Kesting said:
[...]
And each change will need a new Type. And if I understand correctly, that
definition will remain in memory until the application is recycled.

Any ideas?

Create an AppDomain. Load your newly created type into the AppDomain.
After you are done using it, unload the AppDomain. This frees the memory.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top