ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • 좀비 프로세스 | Application.Exit() vs Environmrnt.Exit(0)
    .NET/Basic is the Best 2010. 3. 16. 10:43
    반응형

    좀비 프로세스 - 프로세스 종료 후에도 메모리에서 사라지지않는 프로세스
    좀비 프로세스 발생원인 -  
    자식프로세스가 종료되었는데 부모프로세스가
    종료되지 않았거나, 부모프로세스가 wait()계열 함수를 호출해서 자식프로세스를 정리하지 않았을 경우 발생한다.



    Application.Exit() vs Environmrnt.Exit(0)


    Hi All, 
    When I use applcation.exit() in winForm application, the form closed, but 
    the process is still going!! ( The debug process is still running if debug in 
    VS IDE). Environment.Exit(0) works fine. But how to do in such following 
    scenario: if I need to give 2 option for user,1. Quit 2. Restart.  In Quit 
    option, I use Environment.Exit(0) to confirm the process will be stopped. In 
    Restart option, I can't use Environment.Exit(0) , because following 
    application.restart() can't execute never. but if i use Application.Exit(), 
    the application can restart, but if the user choose quit next time. alas! the 
    process is going!  it won't stop this time. 
    Hope my desception is clear :) 
    Pls Help!!! 

    Taoge wrote: 


    On the topic of your zombie process: 

    Application.Exit causes the Windows UI message loop of the current 
    thread, if any, to exit. Understanding this requires understanding that 
    Windows UIs are based around a simple loop that iteratively retrieves a 
    message and dispatches it. The loop is contained in code called by 
    Application.Run(). So, Application.Exit will cause Application.Run() to 
    return. If the only non-background thread in your application is the one 
    that is showing a UI and which has called Application.Run() at some 
    point in the past, then the process will usually exit some time after 
    Application.Exit is called, assuming not much other code follows the 
    call to Application.Run(). However, if there are other non-background 
    (Thread.IsBackground) threads in the process, or your application does 
    something else after calling Application.Run, then the process won't 
    exit immediately. 

    Environment.Exit(retCode) causes the process to exit, and is more like 
    the Windows API ExitProcess. 

    I suggest you break into the application in the debugger when it is 
    still executing yet has called Application.Exit. Check each thread and 
    see where they are. Some of them will be CLR threads for finalization, 
    GC, debugging, etc., but there should be some user threads in there that 
    are keeping the process alive. 

    -- Barry 




    반응형

    댓글

Designed by Tistory.