user1940350
user1940350

Reputation: 173

Execute code in different AppDomain to extent application memory

My problem that i'm using 32 bit application so i have limited memory usage. I need to execute piece of code (to use some data base) that need lot of memory in parallel and i thought to run this code in different processes (If I'm not mistaken each process get approximately 2 GB's of memory usage) another advantage is any crash on process won't affect the application. I wondering if Appdomain really don't share memory with the main application? If so, this solution will help me? Executing Code in a Separate Application Domain Using C#

Upvotes: 0

Views: 685

Answers (2)

NeddySpaghetti
NeddySpaghetti

Reputation: 13495

App domains does use main application memory however once the app domain is unloaded all the memory is reclaimed, however creating and unloading of the app domain has a performance cost and if the app domain contains lots of static objects it can actually inflate the size of the process as static objects are tied to the app domain and not the process. See Understanding Application Domains.

If the memory intensive part of your application runs for a limited amount of time, you can benefit from this approach, however running in a separate process will allow you to use more memory, especially if this is a x64 process, but you may need to somehow communicate between the two processes.

You can also look at reducing the memory pressure of your application by pooling and reusing objects that consume a lot of memory.

Upvotes: 1

Bogey
Bogey

Reputation: 5734

See Difference between AppDomain, Assembly, Process, and a Thread

An AppDomain isn't usually run in a seperate process to my knowledge; I don't think this would help you there.

Why not spawn a new process directly?

Upvotes: 1

Related Questions