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.

All Process ID

Post Reply
dilfich
Posts: 331
Joined: Thu Nov 30, 2017 1:17 am

All Process ID

Post by dilfich »

Tell me how to find out the ID of all the processes of the browsers?
User avatar
salvadordf
Posts: 4076
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: All Process ID

Post by salvadordf »

The latest CEF4Delphi version has a new property that shows all the process IDs.
Set GlobalCEFApp.LogProcessInfo to TRUE before the GlobalCEFApp.StartMainProcess call in the DPR file and run your app.
A "debug.log" file will be created with some text lines with the Process ID (PID) and the Process Type (PT) of each process.

By default the GlobalCEFApp.SitePerProcess property is true, which could create multiple renderer processes per website. If you set GlobalCEFApp.SitePerProcess to FALSE before the GlobalCEFApp.StartMainProcess call the browser will work correctly with less processes and your debug session will be slightly easier.

This is an example of the "debug.log" file :

Code: Select all

[1024/222029.778:INFO:CEF4Delphi(1)] PID: 2860, TID: 1220, PT: Browser - Process started
[1024/222030.433:INFO:CEF4Delphi(1)] PID: 2104, TID: 2620, PT: GPU - Process started
[1024/222030.435:INFO:CEF4Delphi(1)] PID: 1708, TID: 2472, PT: Renderer - Process started
If you need to know exactly which process runs your javascript extension add this code to your extension code :

Code: Select all

CefDebugLog('THIS IS THE PROCESS I WANT TO DEBUG', CEF_LOG_SEVERITY_INFO);
That CefDebugLog call will write a text line in the "debug.log" file with the process ID, type, etc.
dilfich
Posts: 331
Joined: Thu Nov 30, 2017 1:17 am

Re: All Process ID

Post by dilfich »

Only in file write?
I have more than 10 browsers created in my application. I'll ask otherwise, I want to know the memory occupied by the browser and change the priority of the browser, perhaps something else but you need to know the ID of a particular instance of the browser in the application.
User avatar
salvadordf
Posts: 4076
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: All Process ID

Post by salvadordf »

You can also call GetCurrentProcessID in your code and get the process type from the GlobalCEFApp.ProcessType property.

I guess you should add the memory used by all the processes related to a browser and that can be much harder (if possible).
dilfich
Posts: 331
Joined: Thu Nov 30, 2017 1:17 am

Re: All Process ID

Post by dilfich »

I do not quite understand how and where to call GlobalCEFApp.ProcessType and apply it to GetCurrentProcessID? Okay memory, I want to try to change the priority of all browser processes in the hope that the application will load less CPU. Or is the game not worth it? Simply there are sites where a lot of JS strongly load CPU, and to reduce the number of instances is not an option. :(
ps.
this is not mining)
User avatar
salvadordf
Posts: 4076
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: All Process ID

Post by salvadordf »

I just added some properties to GlobalCEFApp to get some memory usage information.

The new properties are :
  • GlobalCEFApp.UsedMemory : Amount of memory used by all the processes in the application.
  • GlobalCEFApp.TotalSystemMemory : Amount of actual physical memory in the system.
  • GlobalCEFApp.AvailableSystemMemory : Amount of physical memory currently available in the system.
  • GlobalCEFApp.SystemMemoryLoad : Percentage of physical memory that is in use.
The MiniBrowser demo has a new menu option called "Memory info..." that shows all these properties.

Please download the latest CEF4Delphi version and use those properties to create new browsers only when the system is not overloaded.

Try these property values to reduce the memory and CPU usage :
  • Set GlobalCEFApp.cache to a local directory.
  • Set GlobalCEFApp.SitePerProcess to FALSE to reduce the number of processes.
  • Set GlobalCEFApp.DisablePDFExtension to TRUE.
  • Set GlobalCEFApp.DisableExtensions to TRUE.
  • Set GlobalCEFApp.FlashEnabled to FALSE.
  • Set TChromium.Options.ImageLoading to STATE_DISABLED.
  • Set TChromium.Options.Javascript to STATE_DISABLED.
All the GlobalCEFApp properties must be set before the GlobalCEFApp.StartMainProcess call, and all the TChromium properties must be set before the TChromium.CreateBrowser call.
Post Reply