Disclosure Statement: This site contains affiliate links, which means that I may receive a commission if you make a purchase using these links. As an eBay Partner, I earn from qualifying purchases.

Sometime one process can't quit

Post Reply
tad.chen
Posts: 110
Joined: Fri Jan 04, 2019 1:39 am

Sometime one process can't quit

Post by tad.chen »

I find that sometime one process of the browser is still running after the browser quits.

I find it in the task manager window, and the CPU usage of the process is high, about 15%.

I don't know the reason of this issue and don't know how to debug it.

Could you give me some advice?
User avatar
salvadordf
Posts: 4076
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Sometime one process can't quit

Post by salvadordf »

Hi,

Perhaps this CEF issue is related :
https://github.com/chromiumembedded/cef/issues/3532

It would be extremely helpful to have a step-by-step guide to reproduce that issue with a minimal demo.

Once you have a reliable way to reproduce this issue then you can use this guide to debug it if it's a CEF issue :
https://www.briskbard.com/forum/viewtopic.php?f=10&t=1050
tad.chen
Posts: 110
Joined: Fri Jan 04, 2019 1:39 am

Re: Sometime one process can't quit

Post by tad.chen »

Thank you for your information!

This issue is only found in my browser, and occurs randomly. I can't reproduce it with any Demos in cef4Delphi package.

Now, I fixed it by adding some code which kill all processes of the browser after DestroyGlobalCEFApp statement, and it works.
homer
Posts: 3
Joined: Thu Jan 18, 2024 10:54 pm

Re: Sometime one process can't quit

Post by homer »

I have run into the same problem. Could you share how you killed the running instances, please?
dungnn
Posts: 6
Joined: Mon Jan 15, 2024 6:57 am

Re: Sometime one process can't quit

Post by dungnn »

taskkill /pid [mainprocessid] /t /f

replace main process id with GetCurrentProcessId, exec it when form destroy and you'll be fine
tad.chen
Posts: 110
Joined: Fri Jan 04, 2019 1:39 am

Re: Sometime one process can't quit

Post by tad.chen »

homer wrote: Mon Jan 29, 2024 5:22 pm I have run into the same problem. Could you share how you killed the running instances, please?
Sorry, I've not seen your question. I wrote a function to do this.

Code: Select all

procedure KillProcessStillRunning;
var
  TempHandle   : THandle;
  TempProcess  : TProcessEntry32;
  TempPID      : DWORD;
  TempProcHWND : HWND;
  TempMemCtrs  : TProcessMemoryCounters;
  TempMain, TempSubProc, TempName : string;
begin
  TempHandle := CreateToolHelp32SnapShot(TH32CS_SNAPPROCESS, 0);
  if (TempHandle = INVALID_HANDLE_VALUE) then exit;

  ZeroMemory(@TempProcess, SizeOf(TProcessEntry32));
  TempProcess.dwSize := Sizeof(TProcessEntry32);
  TempPID            := GetCurrentProcessID;

  Process32First(TempHandle, TempProcess);

  repeat
    if TempProcess.th32ParentProcessID = TempPID then
    begin
      TempName := TempProcess.szExeFile;
      TerminateProcess(OpenProcess(PROCESS_TERMINATE, BOOL(0),
                          TempProcess.th32ProcessID),0);
    end;
  until not(Process32Next(TempHandle, TempProcess));

  CloseHandle(TempHandle);
end;
Post Reply