Index: /Include/basic.sbp
===================================================================
--- /Include/basic.sbp	(revision 145)
+++ /Include/basic.sbp	(revision 146)
@@ -113,21 +113,44 @@
 
 Sub _System_StartupProgram()
-	'この関数はアプリケーションの起動時にシステムからコールバックされます
+	'Unsafe
 
-	InitializeCriticalSection(_System_CriticalSection)
+		'この関数はアプリケーションの起動時にシステムからコールバックされます
 
-	_System_hProcessHeap=HeapCreate(HEAP_GENERATE_EXCEPTIONS,0,0)
+		InitializeCriticalSection(_System_CriticalSection)
 
-	_System_GC._System_CGarbageCollection()
+		_System_hProcessHeap=HeapCreate(HEAP_GENERATE_EXCEPTIONS,0,0)
 
-	'Initialize global variables
-	_System_InitDllGlobalVariables()
+		' GC管理オブジェクトを生成
+		_System_pGC = _System_calloc( SizeOf( _System_CGarbageCollection ) )
+		_System_pGC->Begin()
 
-	'Initialize static variables
-	_System_InitStaticLocalVariables()
+		'Initialize global variables
+		_System_InitDllGlobalVariables()
+
+		'Initialize static variables
+		_System_InitStaticLocalVariables()
+
+		'TODO:
+		' Set current thread priority
+		'Dim thread = Thread.CurrentThread()
+		'thread.Priority = ThreadPriority.Normal
+
+	'End Unsafe
 End Sub
 
 Sub _System_EndProgram()
-	DeleteCriticalSection(_System_CriticalSection)
+	'Unsafe
+
+		_System_Call_Destructor_of_GlobalObject()
+
+		' GC管理オブジェクトを破棄
+		_System_pGC->Finish()
+		_System_free( _System_pGC )
+
+		DeleteCriticalSection(_System_CriticalSection)
+
+		HeapDestroy( _System_hProcessHeap )
+
+	'End Unsafe
 End Sub
 
