서버 유형의 COM+에 적용할 수 없는 Server GC
다음의 문서에 나오듯이,
Using Per-Application Configuration Files
; https://docs.microsoft.com/en-us/windows/win32/cossdk/using-per-application-configuration-files
서버 유형의 COM+ 응용 프로그램에 app.config을 적용하려면 다음의 2개 파일을 생성한 다음,
[application.manifest 파일]
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" />
[application.config 파일]
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="myValue" value="TEST"/>
</appSettings>
</configuration>
COM+ 응용 프로그램 속성 창의 "Activation(활성화)" 탭에서 "Application Root Directory(응용 프로그램 루트 디렉터리)"를 설정하는 것으로 가능합니다.
그런데 여기서 재미있는 것은, app.config의 모든 설정이 dllhost.exe 프로세스에 적용되지는 않는다는 점입니다. 그 한 사례로, ServerGC 유형에 대한 설정인데요,
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="myValue" value="TEST" />
</appSettings>
<runtime>
<gcServer enabled="true"/>
</runtime>
</configuration>
위와 같이 설정하고 COM+의 Activate 메서드에서 다음과 같이 확인해 보면,
[JustInTimeActivation(true)]
// ...[생략]...
public class TestComplus : ServicedComponent
{
public TestComplus()
{
}
protected override void Activate()
{
string text = System.Configuration.ConfigurationSettings.AppSettings["myValue"];
Environment.SetEnvironmentVariable("TEST_ENV1", text);
Environment.SetEnvironmentVariable("TEST_ENV2", GCSettings.IsServerGC.ToString());
}
// ...[생략]...
}
dllhost.exe 환경 변수의 TEST_ENV1에는 "TEST" 문자열이 있지만, TEST_ENV2에는 "False" 값이 있는 것을 볼 수 있습니다. 실제로, GC가 발생했을 때의 호출 스택을 보면 "WKS" 문자열을 통해 이를 짐작할 수 있습니다.
clr!WKS::gc_heap::mark_phase+197
clr!WKS::gc_heap::gc1+a3
clr!WKS::gc_heap::garbage_collect+54c
clr!WKS::GCHeap::GarbageCollectGeneration+10d
clr!WKS::gc_heap::trigger_gc_for_alloc+2d
clr!WKS::GCHeap::Alloc+2ab
...[생략]...
의도한대로 ServerGC가 사용이 되었다면 "SVR"이 나와야 합니다.
clr!SVR::gc_heap::plan_phase+12bb
clr!SVR::gc_heap::gc1+c3
clr!SVR::gc_heap::garbage_collect+f0
clr!SVR::gc_heap::gc_thread_function+74
clr!SVR::gc_heap::gc_thread_stub+9a
clr!<lambda_5d4b8dc0ce3eb05b864e38505727a1c1>::<lambda_invoker_cdecl>+51
kernel32!BaseThreadInitThunk+14
ntdll!RtlUserThreadStart+21
[이 글에 대해서 여러분들과 의견을 공유하고 싶습니다. 틀리거나 미흡한 부분 또는 의문 사항이 있으시면 언제든 댓글 남겨주십시오.]