[CEF 3.2840.1518] Memory-related crashes

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

[CEF 3.2840.1518] Memory-related crashes

Postby reliasn » Thu Jan 05, 2017 6:28 am

I'm running CEF 3.2840.1518.gffd843 for Windows 32-bit and I'm getting crashes related to "out of memory". These are some sample stacktraces that I've copied from Visual Studio:
Code: Select all
> KernelBase.dll!7640a832() Unknown
[Frames below may be incorrect and/or missing, no symbols loaded for KernelBase.dll] 
libcef.dll!WTF::partitionsOutOfMemoryUsing64M() Line 155  C++
libcef.dll!WTF::Partitions::handleOutOfMemory() Line 197  C++
libcef.dll!WTF::partitionOutOfMemory(const WTF::PartitionRootBase * root=0x13a84f54) Line 326 C++
libcef.dll!WTF::partitionAllocSlowPath(WTF::PartitionRootBase * root, int flags=0, unsigned int size=9437184, WTF::PartitionBucket * bucket=0x00000000) Line 838  C++
libcef.dll!WTF::PartitionAllocator::allocateBacking(unsigned int size=9437184, const char * typeName=0x00000000) Line 40  C++
libcef.dll!blink::CSSTokenizer::Scope::Scope(const WTF::String & string={...}) Line 36  C++
libcef.dll!blink::CSSParserImpl::parseStyleSheet(const WTF::String & string={...}, const blink::CSSParserContext & context={...}, blink::StyleSheetContents * styleSheet=0x597c71b0) Line 171 C++
libcef.dll!blink::StyleSheetContents::parseAuthorStyleSheet(const blink::CSSStyleSheetResource * cachedStyleSheet=0x2d1e6c20, const blink::SecurityOrigin * securityOrigin=0x5ab99b00) Line 346 C++
libcef.dll!blink::LinkStyle::setCSSStyleSheet(const WTF::String & href={...}, const blink::KURL & baseURL={...}, const WTF::String & charset={...}, const blink::CSSStyleSheetResource * cachedStyleSheet=0x2d1e6c20) Line 505  C++
libcef.dll!blink::CSSStyleSheetResource::checkNotify() Line 109 C++
libcef.dll!blink::Resource::finish(double loadFinishTime=15087.187841999999) Line 426 C++
libcef.dll!blink::ResourceFetcher::didFinishLoading(blink::Resource * resource=0x2d1e6c20, double finishTime=15087.187841999999, __int64 encodedDataLength=0, blink::ResourceFetcher::DidFinishLoadingReason finishReason=DidFinishLoading) Line 954  C++
libcef.dll!blink::ResourceLoader::didFinishLoading(blink::WebURLLoader * __formal=0x2890aa70, double finishTime=15087.187841999999, __int64 encodedDataLength=0) Line 183 C++
libcef.dll!content::WebURLLoaderImpl::Context::OnCompletedRequest(int error_code=0, bool was_ignored_by_handler=false, bool stale_copy_in_cache=true, const std::basic_string<char,std::char_traits<char>,std::allocator<char> > & security_info={...}, const base::TimeTicks & completion_time={...}, __int64 total_transfer_size=0) Line 783  C++
libcef.dll!content::WebURLLoaderImpl::RequestPeerImpl::OnCompletedRequest(int error_code=0, bool was_ignored_by_handler=false, bool stale_copy_in_cache=true, const std::basic_string<char,std::char_traits<char>,std::allocator<char> > & security_info={...}, const base::TimeTicks & completion_time={...}, __int64 total_transfer_size=0) Line 929  C++
libcef.dll!content::ResourceDispatcher::OnRequestComplete(int request_id=680569536, const content::ResourceRequestCompletionStatus & request_complete_data={...}) Line 432  C++
libcef.dll!IPC::MessageT<ResourceMsg_RequestComplete_Meta,std::tuple<int,content::ResourceRequestCompletionStatus>,void>::Dispatch<content::ResourceDispatcher,content::ResourceDispatcher,void,void (__thiscall content::ResourceDispatcher::*)(int,content::ResourceRequestCompletionStatus const &)>(const IPC::Message * msg=0x404d39c8, content::ResourceDispatcher * obj=0x0cd97080, content::ResourceDispatcher * sender=0x0cd97080, void * parameter=0x00000000, void(content::ResourceDispatcher::*)(int, const content::ResourceRequestCompletionStatus &) func=0x1230c01c) Line 121  C++
libcef.dll!content::ResourceDispatcher::DispatchMessageW(const IPC::Message & message={...}) Line 557 C++
libcef.dll!content::ResourceDispatcher::OnMessageReceived(const IPC::Message & message={...}) Line 170  C++
libcef.dll!base::internal::InvokeHelper<1,void>::MakeItSo<void (__thiscall content::PepperGamepadHost::*const &)(ppapi::host::ReplyMessageContext const &),base::WeakPtr<content::PepperGamepadHost> const &,ppapi::host::ReplyMessageContext const &>(void(content::PepperGamepadHost::*)(const ppapi::host::ReplyMessageContext &) & functor=0x12fdebb8, const base::WeakPtr<content::PepperGamepadHost> & weak_ptr={...}, const ppapi::host::ReplyMessageContext & <args_0>={...}) Line 303  C++
libcef.dll!base::internal::Invoker<base::internal::BindState<void (__thiscall gpu::GpuChannel::*)(IPC::Message const &),base::WeakPtr<gpu::GpuChannel>,IPC::Message>,void __cdecl(void)>::Run(base::internal::BindStateBase * base=0x404d39b8) Line 324 C++
libcef.dll!base::debug::TaskAnnotator::RunTask(const char * queue_function=0x134bb7ac, const base::PendingTask & pending_task={...}) Line 54  C++
libcef.dll!blink::scheduler::TaskQueueManager::ProcessTaskFromWorkQueue(blink::scheduler::internal::WorkQueue * work_queue, blink::scheduler::internal::TaskQueueImpl::Task * out_previous_task=0x0cc5f044) Line 319  C++
libcef.dll!blink::scheduler::TaskQueueManager::DoWork(base::TimeTicks run_time={...}, bool from_main_thread) Line 218 C++
libcef.dll!base::internal::FunctorTraits<void (__thiscall content::WebFileWriterBase::*)(__int64,bool),void>::Invoke<base::WeakPtr<content::WebFileWriterImpl> const &,__int64,bool>(void(content::WebFileWriterBase::*)(__int64, bool) method=0x1237ea0c, const base::WeakPtr<content::WebFileWriterImpl> & receiver_ptr={...}, __int64 && <args_0>=0, bool && <args_1>=true) Line 215 C++
libcef.dll!base::internal::InvokeHelper<1,void>::MakeItSo<void (__thiscall content::devtools::network::NetworkHandler::*const &)(content::DevToolsCommandId,bool),base::WeakPtr<content::devtools::network::NetworkHandler> const &,content::DevToolsCommandId const &,bool>(void(content::devtools::network::NetworkHandler::*)(content::DevToolsCommandId, bool) & functor=0x1237ea0c, const base::WeakPtr<content::devtools::network::NetworkHandler> & weak_ptr={...}, const content::DevToolsCommandId & <args_0>={...}, bool && <args_1>=true) Line 303 C++
libcef.dll!base::internal::Invoker<base::internal::BindState<void (__thiscall blink::scheduler::TaskQueueManager::*)(base::TimeTicks,bool),base::WeakPtr<blink::scheduler::TaskQueueManager>,base::TimeTicks,bool>,void __cdecl(void)>::RunImpl<void (__thiscall blink::scheduler::TaskQueueManager::*const &)(base::TimeTicks,bool),std::tuple<base::WeakPtr<blink::scheduler::TaskQueueManager>,base::TimeTicks,bool> const &,0,1,2>(void(blink::scheduler::TaskQueueManager::*)(base::TimeTicks, bool) & functor=0x1237ea0c, const std::tuple<base::WeakPtr<blink::scheduler::TaskQueueManager>,base::TimeTicks,bool> & bound={...}, base::IndexSequence<0,1,2> __formal={...}) Line 346 C++
libcef.dll!base::internal::Invoker<base::internal::BindState<void (__thiscall blink::scheduler::TaskQueueManager::*)(base::TimeTicks,bool),base::WeakPtr<blink::scheduler::TaskQueueManager>,base::TimeTicks,bool>,void __cdecl(void)>::Run(base::internal::BindStateBase * base=0x0cd16a50) Line 324 C++
libcef.dll!base::debug::TaskAnnotator::RunTask(const char * queue_function=0x138d6c28, const base::PendingTask & pending_task={...}) Line 54  C++
libcef.dll!base::MessageLoop::RunTask(const base::PendingTask & pending_task={...}) Line 486  C++
libcef.dll!base::MessageLoop::DoWork() Line 618 C++
libcef.dll!base::MessagePumpForUI::DoRunLoop() Line 263 C++
libcef.dll!base::MessagePumpWin::Run(base::MessagePump::Delegate * delegate=0x076c41f0) Line 142  C++
libcef.dll!base::RunLoop::Run() Line 36 C++
libcef.dll!base::Thread::Run(base::RunLoop * run_loop=0x0cc5ff14) Line 229  C++
libcef.dll!base::Thread::ThreadMain() Line 304  C++
libcef.dll!base::`anonymous namespace'::ThreadFunc(void * params=0x0cd6ac90) Line 86  C++
kernel32.dll!@BaseThreadInitThunk@12() Unknown
ntdll.dll!__RtlUserThreadStart()  Unknown
ntdll.dll!__RtlUserThreadStart@8() Unknown

Code: Select all
> libcef.dll!WTF::partitionsOutOfMemoryUsing64M() Line 155  C++
libcef.dll!WTF::Partitions::handleOutOfMemory() Line 197  C++
libcef.dll!WTF::partitionOutOfMemory(const WTF::PartitionRootBase * root=0x083c4f54) Line 326 C++
libcef.dll!WTF::partitionAllocSlowPath(WTF::PartitionRootBase * root=0x083c4f54, int flags=0, unsigned int size=2392064, WTF::PartitionBucket * bucket=0x00000000) Line 838 C++
libcef.dll!WTF::PartitionAllocator::allocateBacking(unsigned int size=2392064, const char * typeName=0x07c80edc) Line 40  C++
libcef.dll!WTF::PartitionAllocator::allocateVectorBacking<char>(unsigned int size=2392064) Line 56  C++
libcef.dll!WTF::VectorBufferBase<char,1,WTF::PartitionAllocator>::allocateBuffer(unsigned int newCapacity=2388057) Line 353 C++
libcef.dll!WTF::VectorBuffer<char,1024,WTF::PartitionAllocator>::VectorBuffer<char,1024,WTF::PartitionAllocator>(unsigned int capacity=2388057) Line 533  C++
libcef.dll!WTF::Vector<char,1024,WTF::PartitionAllocator>::Vector<char,1024,WTF::PartitionAllocator>(unsigned int size=2388057) Line 823  C++
libcef.dll!WTF::String::utf8(WTF::UTF8ConversionMode mode=LenientUTF8Conversion) Line 713 C++
libcef.dll!WTF::StringUTF8Adaptor::StringUTF8Adaptor(const WTF::String & string={...}) Line 62  C++
libcef.dll!blink::WebString::utf8() Line 78 C++
libcef.dll!CefBrowserImpl::OnRequest(const Cef_Request_Params & params={...}) Line 604  C++
libcef.dll!base::DispatchToMethodImpl<content::GpuChildThread *,void (__thiscall content::GpuChildThread::*)(std::basic_string<char,std::char_traits<char>,std::allocator<char> > const &),std::tuple<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > const &,0>(content::GpuChildThread * const & obj=0x0dee1740, void(content::GpuChildThread::*)(const std::basic_string<char,std::char_traits<char>,std::allocator<char> > &) method=0x06328548, const std::tuple<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > & args={...}, base::IndexSequence<0> __formal={...}) Line 145 C++
libcef.dll!base::DispatchToMethod<CefBrowserHostImpl *,void (__thiscall CefBrowserHostImpl::*)(Cef_Request_Params const &),std::tuple<Cef_Request_Params> const &>(CefBrowserHostImpl * const & obj=0x0dee1740, void(CefBrowserHostImpl::*)(const Cef_Request_Params &) method=0x06328548, const std::tuple<Cef_Request_Params> & args={...}) Line 151  C++
libcef.dll!IPC::DispatchToMethod<CefBrowserHostImpl,void (__thiscall CefBrowserHostImpl::*)(Cef_Request_Params const &),void,std::tuple<Cef_Request_Params> >(CefBrowserHostImpl * obj=0x0dee1740, void(CefBrowserHostImpl::*)(const Cef_Request_Params &) method=0x06328548, void * __formal=0x00000000, const std::tuple<Cef_Request_Params> & tuple={...}) Line 26 C++
libcef.dll!IPC::MessageT<CefMsg_Request_Meta,std::tuple<Cef_Request_Params>,void>::Dispatch<CefBrowserImpl,CefBrowserImpl,void,void (__thiscall CefBrowserImpl::*)(Cef_Request_Params const &)>(const IPC::Message * msg=0x45836ef0, CefBrowserImpl * obj=0x0dee1740, CefBrowserImpl * sender=0x0dee1740, void * parameter=0x00000000, void(CefBrowserImpl::*)(const Cef_Request_Params &) func=0x06328548) Line 121  C++
libcef.dll!CefBrowserImpl::OnMessageReceived(const IPC::Message & message={...}) Line 521 C++
libcef.dll!content::RenderViewImpl::OnMessageReceived(const IPC::Message & message={...}) Line 1300 C++
libcef.dll!IPC::MessageRouter::RouteMessage(const IPC::Message & msg={...}) Line 52 C++
libcef.dll!IPC::MessageRouter::OnMessageReceived(const IPC::Message & msg={...}) Line 45  C++
libcef.dll!content::ChildThreadImpl::OnMessageReceived(const IPC::Message & msg={...}) Line 775 C++
libcef.dll!IPC::ChannelProxy::Context::OnDispatchMessage(const IPC::Message & message={...}) Line 315 C++
libcef.dll!base::internal::Invoker<base::internal::BindState<base::internal::IgnoreResultHelper<bool (__thiscall content::UtilityProcessHostClient::*)(IPC::Message const &)>,scoped_refptr<content::UtilityProcessHostClient>,IPC::Message>,void __cdecl(void)>::Run(base::internal::BindStateBase * base=0x45836ee0) Line 328 C++
libcef.dll!base::debug::TaskAnnotator::RunTask(const char * queue_function=0x07dfb7ac, const base::PendingTask & pending_task={...}) Line 54  C++
libcef.dll!blink::scheduler::TaskQueueManager::ProcessTaskFromWorkQueue(blink::scheduler::internal::WorkQueue * work_queue, blink::scheduler::internal::TaskQueueImpl::Task * out_previous_task=0x0eeced04) Line 319  C++
libcef.dll!blink::scheduler::TaskQueueManager::DoWork(base::TimeTicks run_time={...}, bool from_main_thread) Line 218 C++
libcef.dll!base::internal::FunctorTraits<void (__thiscall content::WebFileWriterBase::*)(__int64,bool),void>::Invoke<base::WeakPtr<content::WebFileWriterImpl> const &,__int64,bool>(void(content::WebFileWriterBase::*)(__int64, bool) method=0x06cbea0c, const base::WeakPtr<content::WebFileWriterImpl> & receiver_ptr={...}, __int64 && <args_0>=0, bool && <args_1>=true) Line 215 C++
libcef.dll!base::internal::InvokeHelper<1,void>::MakeItSo<void (__thiscall content::devtools::network::NetworkHandler::*const &)(content::DevToolsCommandId,bool),base::WeakPtr<content::devtools::network::NetworkHandler> const &,content::DevToolsCommandId const &,bool>(void(content::devtools::network::NetworkHandler::*)(content::DevToolsCommandId, bool) & functor=0x06cbea0c, const base::WeakPtr<content::devtools::network::NetworkHandler> & weak_ptr={...}, const content::DevToolsCommandId & <args_0>={...}, bool && <args_1>=true) Line 303 C++
libcef.dll!base::internal::Invoker<base::internal::BindState<void (__thiscall blink::scheduler::TaskQueueManager::*)(base::TimeTicks,bool),base::WeakPtr<blink::scheduler::TaskQueueManager>,base::TimeTicks,bool>,void __cdecl(void)>::RunImpl<void (__thiscall blink::scheduler::TaskQueueManager::*const &)(base::TimeTicks,bool),std::tuple<base::WeakPtr<blink::scheduler::TaskQueueManager>,base::TimeTicks,bool> const &,0,1,2>(void(blink::scheduler::TaskQueueManager::*)(base::TimeTicks, bool) & functor=0x06cbea0c, const std::tuple<base::WeakPtr<blink::scheduler::TaskQueueManager>,base::TimeTicks,bool> & bound={...}, base::IndexSequence<0,1,2> __formal={...}) Line 346 C++
libcef.dll!base::internal::Invoker<base::internal::BindState<void (__thiscall blink::scheduler::TaskQueueManager::*)(base::TimeTicks,bool),base::WeakPtr<blink::scheduler::TaskQueueManager>,base::TimeTicks,bool>,void __cdecl(void)>::Run(base::internal::BindStateBase * base=0x0b1172b0) Line 324 C++
libcef.dll!base::debug::TaskAnnotator::RunTask(const char * queue_function=0x08216c28, const base::PendingTask & pending_task={...}) Line 54  C++
libcef.dll!base::MessageLoop::RunTask(const base::PendingTask & pending_task={...}) Line 486  C++
libcef.dll!base::MessageLoop::DoWork() Line 618 C++
libcef.dll!base::MessagePumpForUI::DoRunLoop() Line 263 C++
libcef.dll!base::MessagePumpWin::Run(base::MessagePump::Delegate * delegate=0x0b26c538) Line 142  C++
libcef.dll!base::RunLoop::Run() Line 36 C++
libcef.dll!base::Thread::Run(base::RunLoop * run_loop=0x0eecfbd4) Line 229  C++
libcef.dll!base::Thread::ThreadMain() Line 304  C++
libcef.dll!base::`anonymous namespace'::ThreadFunc(void * params=0x0dd1c328) Line 86  C++
kernel32.dll!@BaseThreadInitThunk@12() Unknown
ntdll.dll!__RtlUserThreadStart()  Unknown
ntdll.dll!__RtlUserThreadStart@8() Unknown

I am creating 8 browsers in Single Process mode and making them constantly reload URLs. After about 5-6minutes of usage, my application crashes and the crash log that my VectoredExceptionHandler creates has the following memory/error info:
Code: Select all
GetLastError         : 8
LastErrorMsg         : Not enough storage is available to process this command.
Total Phys Mem       : 17073737728 16282.79MB
Phys Mem Used        : 8305459200 7920.70MB 48.64 %
Proc Phys Mem        : 956280832 911.98MB 5.60 %
Total Virtual Mem    : 19623874560 18714.79MB
Virtual Mem Used     : 11325886464 10801.21MB 57.71 %
Proc Virtual Mem     : 728367104 694.63MB 3.71 %

I'm constantly calling CefFrame::GetSource when a browser finishes loading a page. By finished, I mean when isLoading is false and the last resource request happened more than 1s ago. I also work mainly with std::string and I have this structure:
Code: Select all
class xRequest {
public:
    string url;
    int status = 0;
    int64 content_length = 0;
    uint64 id = 0;
    map<string, string> reqHeaders, resHeaders;
};
map<uint64, vector<xRequest>> requestMap;

where I store all requests during a page load. The map is cleared upon starting a new page load. I also store the request headers, response headers and other info. It's a vector because it handles redirections as well, which have the same request ID until the final response is received.

I added so many details because I'm somewhat lost and I think it's a memory leak issue related to my implementation. I'm aware that Single Process is not supported and I hope it's nothing related to it. I will soon do some testing with multiple processes and see if I get the same behavior. For now, I'd appreciate if anyone could give me any inputs on this problem that I'm experiencing.

Thanks for your attention.

PS: The 8 browsers and the constant reloads were created just to speed up the crash because I usually get it after about 2-3h of application usage.
reliasn
Newbie
 
Posts: 5
Joined: Sun Sep 25, 2016 4:55 am

Re: [CEF 3.2840.1518] Memory-related crashes

Postby amaitland » Thu Jan 05, 2017 7:35 pm

Unsupported really does mean unsupported in this case, Single process mode is not suitable for production use.

Make sure your using /LARGEADDRESSAWARE or switch to a 64bit build. Won't fix your leak, will just make your app more stable. Ultimately you'll need to switch to multi process mode.

Also 2883 and 2924 are the currently supported versions

https://bitbucket.org/chromiumembedded/ ... -supported
Maintainer of the CefSharp project.
amaitland
Virtuoso
 
Posts: 1292
Joined: Wed Jan 14, 2015 2:35 am

Re: [CEF 3.2840.1518] Memory-related crashes

Postby reliasn » Sat Jan 07, 2017 3:07 pm

I switched to multi-process mode and indeed, it's much more stable. I don't get any crashes and it kinda feels like the memory usage got distributed across the processes. This is the memory usage according to Visual Studio's Diagnostic Tools:
Image
The growth starts when I hit the "Leak" button in my application, which creates all 8 browsers and starts the reloads. For 1-2 minutes the memory usage grows fast, but then it gets somewhat "stable". I monitored for a while and noticed the RAM of the main process still grows but quite slower.

I will update to the latest CEF version and see if I get different results. I used CEF's C-API for a while and I must say I got a little "scared" with the pointers and how their reference count gets incremented/decremented. So after switching to libcef_wrapper's C++, I'm being a paranoid about misusing something. Some other details about how I'm using CEF:
- I don't use a CefApp. I pass NULL to my CefInitialize.
- My handler has the following overloads:
Code: Select all
class SimpleHandler :   public CefClient,
                        public CefDisplayHandler,
                        public CefLifeSpanHandler,
                        public CefLoadHandler,
                        public CefJSDialogHandler,
                        public CefRequestHandler,
                        public CefFocusHandler
{
 public:
  SimpleHandler();
  ~SimpleHandler();

  // Provide access to the single global instance of this object.
  static SimpleHandler* GetInstance();

  // CefClient methods:
  virtual CefRefPtr<CefDisplayHandler> GetDisplayHandler() OVERRIDE {
    return this;
  }
  virtual CefRefPtr<CefLifeSpanHandler> GetLifeSpanHandler() OVERRIDE {
    return this;
  }
  virtual CefRefPtr<CefLoadHandler> GetLoadHandler() OVERRIDE {
    return this;
  }
  virtual CefRefPtr<CefJSDialogHandler> GetJSDialogHandler() OVERRIDE {
    return this;
  }
  virtual CefRefPtr<CefRequestHandler> GetRequestHandler() OVERRIDE {
    return this;
  }
  virtual CefRefPtr<CefFocusHandler> GetFocusHandler() OVERRIDE {
    return this;
  }

  // CefDisplayHandler methods:
  virtual bool OnConsoleMessage(CefRefPtr<CefBrowser> browser, const CefString& message, const CefString& source, int line) OVERRIDE;

  // CefLifeSpanHandler methods:
  virtual void OnAfterCreated(CefRefPtr<CefBrowser> browser) OVERRIDE;
  virtual bool DoClose(CefRefPtr<CefBrowser> browser) OVERRIDE;
  virtual void OnBeforeClose(CefRefPtr<CefBrowser> browser) OVERRIDE;
  virtual bool OnBeforePopup(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, const CefString& target_url, const CefString& target_frame_name,
    CefLifeSpanHandler::WindowOpenDisposition target_disposition, bool user_gesture, const CefPopupFeatures& popupFeatures, CefWindowInfo& windowInfo, CefRefPtr<CefClient>& client,
    CefBrowserSettings& settings, bool* no_javascript_access) OVERRIDE;

  // CefLoadHandler methods:
  virtual void OnLoadStart(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, TransitionType transition_type) OVERRIDE;
  virtual void OnLoadEnd(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, int httpStatusCode) OVERRIDE;
  virtual void OnLoadError(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, ErrorCode errorCode, const CefString& errorText,
                           const CefString& failedUrl) OVERRIDE;
  virtual void OnLoadingStateChange(CefRefPtr<CefBrowser> browser, bool isLoading, bool canGoBack, bool canGoForward) OVERRIDE;

  // CefJSDialogHandler methods:
  virtual bool OnJSDialog(CefRefPtr<CefBrowser> browser, const CefString& origin_url, JSDialogType dialog_type, const CefString& message_text,
    const CefString& default_prompt_text, CefRefPtr<CefJSDialogCallback> callback, bool& suppress_message) OVERRIDE;
  virtual bool OnBeforeUnloadDialog(CefRefPtr<CefBrowser> browser, const CefString& message_text, bool is_reload,
                                    CefRefPtr<CefJSDialogCallback> callback) OVERRIDE;

  // CefRequestHandler methods:
  virtual CefRequestHandler::ReturnValue OnBeforeResourceLoad( CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, CefRefPtr<CefRequest> request,
    CefRefPtr<CefRequestCallback> callback) OVERRIDE;
  virtual void OnResourceLoadComplete(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, CefRefPtr<CefRequest> request, CefRefPtr<CefResponse> response,
    URLRequestStatus status, int64 received_content_length) OVERRIDE;
  virtual void OnResourceRedirect(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, CefRefPtr<CefRequest> request, CefRefPtr<CefResponse> response, CefString& new_url) OVERRIDE;
  virtual bool OnResourceResponse(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, CefRefPtr<CefRequest> request, CefRefPtr<CefResponse> response) OVERRIDE;

  // CefFocusHandler methods:
  virtual bool OnSetFocus(CefRefPtr<CefBrowser> browser, FocusSource source) OVERRIDE;

  // Request that all existing browser windows close.
  void CloseAllBrowsers(bool force_close);

  bool IsClosing() const { return is_closing_; }

  // List of existing browser windows. Only accessed on the CEF UI thread.
  typedef std::list<CefRefPtr<CefBrowser> > BrowserList;
  BrowserList browser_list_;
  map<int, xBrowser*> browserMap;

  bool is_closing_;

  // Custom methods
  void getFrameSource(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame);
  void fillResponse(CefRefPtr<CefBrowser> browser, uint64 requestId, CefRefPtr<CefResponse> response, int64 received_content_length);

  // Include the default reference counting implementation.
  IMPLEMENT_REFCOUNTING(SimpleHandler);
};

- Each CEF browser sends requests with a different User Agent. So in my OnBeforeResourceLoad, I iterate the CefRequest::HeaderMap and replace the User-Agent header with the custom one that I set. Back when I was using the C-API, I had to alloc/free the header map, but since this is already done by the CefRequest::HeaderMap, I don't think there are any leaks here.

Anyways, what matters is that the crashes stopped and even if there's still a problem related to memory, I hope it takes a very long time until my application crashes due to it.
reliasn
Newbie
 
Posts: 5
Joined: Sun Sep 25, 2016 4:55 am


Return to Support Forum

Who is online

Users browsing this forum: No registered users and 101 guests