[Mono-dev] Embedded Mono/Program freezes
Robert Jordan
robertj at gmx.net
Sun Aug 20 12:04:00 EDT 2006
Janne Rantala wrote:
> 2006/8/20, Robert Jordan <robertj at gmx.net>:
>> I can reproduce it. The socket connection to the web server
>> hosting the web service remains open after the first
>> mono_runtime_exec_managed_code terminates and the second
>> run freezes the process.
>>
>> If I use mono_thread_attach, everything works as expected.
>>
>> You should really try to get mono_thread_attach running,
>> because mono_runtime_exec_managed_code looks deprecated.
>>
>> How do you load mono-1.dll? LoadLibrary? If so, when?
>> If you don't load it right after the process starts,
>> the GC will miss all threads that have been created
>> in the meanwhile.
>>
>> Robert
>
> That's it! Mono is loaded with LoadLibrary, but before that is done,
> there were some threads that had already been initialized and like you
> said GC must have missed those. So when I load Mono before threads are
> initialized and remove that mono_runtime_exec_managed code and I'm not
> getting that GC -error anymore. And the best part is that I can run
> that program as many times as I want without any errors :)
>
> Thanks a lot Robert!
>
> By the way, do you know how exactly Mono uses those threads? I'm just
> wondering if it has any affect on the normal use of our server-client
> program.
"If I understand the code correctly" (TM) :-):
Threads monitored by the GC, in your case those threads created
after LoadLibrary, are subject to be suspended during a garbage
collection, even if they actually don't run managed code, thus
there might be some theoretical impact on unrelated threads.
Please don't ask me about performance implications of the GC,
because I have no idea. You may be able to time this empirically
by setting the env var GC_DONT_GC=1 and compare the results.
Robert
More information about the Mono-devel-list
mailing list