High render sub-process memory consumption
What version of the product are you using? -57.0.0 (3.2987.1601)
What architecture x86 or x64? -x86
On what operating system? -Win10
Are you using WinForms, WPF or OffScreen? -WinForms (but it is relevant to the WPF too)
What steps will reproduce the problem? 1)Run the official project 'CefSharp.WinForms.Example' 2)Check sub-process memory consumption. Should be comparable to the CEFClient sub-process one.
Description
I found that the CefSharp sub-process memory consumption is higher than CEFClient sub-process one. For example if you start these apps with url google.com then the sub-process memory is as follow:
CefSharp sub-process-> around 44MB (Private memory in the Resource Monitor) CefClient sub-process-> around 26MB (Private memory in the Resource Monitor)
I've tried to find (or understand) why there is such difference in the memory consumption but I didn't have any success. The most interesting thing is that if you start many times CefSharp.WinForms.Example it is possible sometimes to have memory consumption comparable to the CEFClient (it seems that there is some race). It is reproducible with DEBUG, RELEASE and out of the VS.
I'll try to figure out where is the problem but I'll be happy if you share with me your suggestions.
Stefan Bozov
+1 - I can also see higher consumption compared to CEF simple client / CEF client
My environment is similar to the reported - windows 10/ CefSharp 57.0.0 (3.2987.1601)
The default CefSharp sub-process is a c# program, meaning it loads the JIT-compiler and also has a GC using resources. The cefclient one is a native program, which has neither, have you tried using Ngen to see if it helps with the JIT part?
The very first thing that I did was to profile the memory (ANTS Memory profiler):

As you can see the managed memory is so small that there is no need to be conspired at all. I don't think Ngen will do the difference. I don't think CLR itself can have great impact on process's memory.
As I mentioned the most interesting think is that if you start CEFSharp many times (let say with google.com) then you will hit run which consumes as much memory as CEFClient.
Thank you very much for your support.
I managed to reproduce the memory difference between different CefSharp runs (url -> about:blank). Resource Monitor (last two colomns are Shareable memory and Private memory):

The interesting thing is that the last start have less private memory and bigger shareable one.
Using CEFClient:

CEFClient render process PID: 6288
Does it only happen in the example? Could be the things CefSharp registers, can you reproduce in https://github.com/cefsharp/CefSharp.MinimalExample ?
Yes, it is reproducible with the minimal example. Also it is reproducible with Windows 7 and with VM. Also I've did the following:
- Set NULL for CefApp - CefExecuteProcess(cefMainArgs, NULL, NULL); The idea is to break the communication between CefSharp and Cef
- Remove all WCF related logic including WCF references
There was not positive result - the issue persist.
I have an update about this issue. Finally I figure out where is the core problem - It seems that libcef.dll code fragment (.text) is not shared among all sub-process instances. This can be checked with VMMap tool. The issue can be resolved if IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE flag is disabled (using CFF Explorer tool). This issue is not reproducible on every machine.
It seems that the solution will open security hole. It'll be really valuable if you share your opinion about this.
I don't think this is something we should do
Why was this closed?
@Kazumz the issue @StBozov found was the fact the .text fragment was loaded into each process. The resolution required disabling ASLR which is a security risk which is likely why @merceyz closed it. If you think there is another RC or another solution it would be good to hear.