question

forfcw avatar image
0 Votes"
forfcw asked Bruce-SqlWork commented

AppDomain and ThreadPool

Does all processes shared one AppDomain in .netcore 3+ as mentioned in HERE ? What is the relationship of threadpool, process and appdomain in .netcore 3+ and how can I verify it ?
Thanks!





dotnet-runtime
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

Bruce-SqlWork avatar image
1 Vote"
Bruce-SqlWork answered Bruce-SqlWork commented

Processes don’t share an appdomain, in .net core, each process supports one “appdomain”.

In the old framework, an appdomain was an isolation tool. A process could host multiple appdomains and they could communicate with each other via marshaling. An appdomain could be unloaded. This was commonly used for plugin architecture. The plug-in could crash without hurting other host domains. Domains could load other domains. So they could be controlled with c# code.

None of this support was added to .net core. Instead they have focused on loading and unloading assemblies similar to c/c++

In reality there is no real appdomain support in .net core. .net core is runtime hosted by an application.

· 6
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thanks for response.
I got a problem that System.Threading.Tasks.Task would not be executed when I start 3-4 processes and each process starting many threads. Obviously, the thread pool is consumed, but not by one process, but by all processes in .netcore.

0 Votes 0 ·

each process has its own thread pool as threads are owned by processes.

are you sure you know what a process is? how are you starting a process?









0 Votes 0 ·

I couldn't help laughing
dotnet test.dll or just click the test.exe

0 Votes 0 ·

Hi @forfcw ,

when I start 3-4 processes and each process starting many threads. Obviously, the thread pool is consumed, but not by one process, but by all processes in .netcore.

Could you provide more details of the sentence?
In order to help us reproduce the problem, you can consider sharing a sample here.

0 Votes 0 ·

it's not easy to share a sample here. But after searching documents in MSDN, I just want to confirm something in .net core:

  • Different processes get different AppDomain.

  • Thread pools are completely isolated in different processes.

Here is the screenshot from MSDN with "For .NET Core, there is exactly one AppDomain."
140479-image.png


0 Votes 0 ·
image.png (75.6 KiB)

That is correct. In .net core a process can host one appdomain. Threads are owned by a process. Threads actually share the same process memory, but have individual stacks. A thread pool is just a collection of process threads used by the process to manage threads. A process can have multiple thread pools.

Other than using up O/S resources, the threads in one process have no effect on the threads in another.

You have not stated your actual issue, but thread limits are probably not it. Virtual Memory is the main limit. If you are using 32 bit windows you hit a limit at about 2000 threads a process due to stack allocation.

0 Votes 0 ·