[webkit-dev] Out-of-memory handling
Hi Webkit Folks! We are thinking about how to deal with out-of-memory situation. A tempting approach would be using exception handling. E.g., what if we could catch a bad_alloc exception? Would there be any way to simply force WebKit from the browser to "shutdown" itself? When I say shutdown, I mean exiting in an elegant way, e.g., we could save history and other important information to disk (so that when the browser restarts, some info does not get lost). Particularly, we are working with the Qt port, but we are interested in a general solution as well. Best regards, Balázs Kelemen ___ webkit-dev mailing list webkit-dev@lists.webkit.org http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev
Re: [webkit-dev] Out-of-memory handling
On Dec 8, 2008, at 8:21 AM, Kelemen Balázs wrote: A tempting approach would be using exception handling. E.g., what if we could catch a bad_alloc exception? To use exception handling you'd probably have to change all the WebKit code to do cleanup when an exception is propagating. Otherwise, exiting an arbitrary function half way through could leave data structures in an inconsistent state. Fixing this is a large project, almost certainly impractical. Would there be any way to simply force WebKit from the browser to "shutdown" itself? When I say shutdown, I mean exiting in an elegant way, e.g., we could save history and other important information to disk (so that when the browser restarts, some info does not get lost). Sure, you could do that if you make sure that the "important information" is stored in data structures that have some sort of integrity guarantee, which are not manipulated directly by the WebCore/ WebKit code. And make sure the code that writes those data structures can function without allocating additional memory. But I don't think there's any real advantage to using exception handling for this. You could have a function called when out of memory that does this work. Another approach is to save history and other important information as you go. So if you run out of memory there's nothing that needs to be done. -- Darin ___ webkit-dev mailing list webkit-dev@lists.webkit.org http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev
Re: [webkit-dev] Out-of-memory handling
You can check the Nokia's S60WebKit MemoryManager implementation. They have developed a method to handle out of memory situations in WebKit On Tue, Dec 9, 2008 at 12:07 AM, Darin Adler wrote: > On Dec 8, 2008, at 8:21 AM, Kelemen Balázs wrote: > > A tempting approach would be using exception handling. E.g., what if we >> could catch a bad_alloc exception? >> > > To use exception handling you'd probably have to change all the WebKit code > to do cleanup when an exception is propagating. Otherwise, exiting an > arbitrary function half way through could leave data structures in an > inconsistent state. > > Fixing this is a large project, almost certainly impractical. > > Would there be any way to simply force WebKit from the browser to >> "shutdown" itself? When I say shutdown, I mean exiting in an elegant way, >> e.g., we could save history and other important information to disk (so that >> when the browser restarts, some info does not get lost). >> > > Sure, you could do that if you make sure that the "important information" > is stored in data structures that have some sort of integrity guarantee, > which are not manipulated directly by the WebCore/WebKit code. And make sure > the code that writes those data structures can function without allocating > additional memory. > > But I don't think there's any real advantage to using exception handling > for this. You could have a function called when out of memory that does this > work. > > Another approach is to save history and other important information as you > go. So if you run out of memory there's nothing that needs to be done. > >-- Darin > > > ___ > webkit-dev mailing list > webkit-dev@lists.webkit.org > http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev > ___ webkit-dev mailing list webkit-dev@lists.webkit.org http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev
Re: [webkit-dev] Out-of-memory handling
Yes I do. Nokia's Memory manager has a memory collector which goes and collects memory if the available application memory goes below certain threshold. It collects memory from WebCore cache. If the collected memory is not enough then it goes ahead and stops all the browser loads and notifies the browser application about the out of memory situation. In WebKit they have added OOM (Out Of Memory) conditions in various places (javascript parsing/execution, html tokenizer, text encoding, image decoding etc..) and if there is not enough memory then it gracefully fails. Regards Kulanthaivel On Fri, Dec 19, 2008 at 12:58 PM, Paul Pedriana wrote: > You don't happen to know anything about the approach Nokia took, do you? > > Thanks > > Paul > > > You can check the Nokia's S60WebKit MemoryManager implementation. They have > developed a method to handle out of memory situations in WebKit > > On Tue, Dec 9, 2008 at 12:07 AM, Darin Adler wrote: > >> On Dec 8, 2008, at 8:21 AM, Kelemen Balázs wrote: >> >> A tempting approach would be using exception handling. E.g., what if we >>> could catch a bad_alloc exception? >>> >> >> To use exception handling you'd probably have to change all the WebKit >> code to do cleanup when an exception is propagating. Otherwise, exiting an >> arbitrary function half way through could leave data structures in an >> inconsistent state. >> >> Fixing this is a large project, almost certainly impractical. >> >> Would there be any way to simply force WebKit from the browser to >>> "shutdown" itself? When I say shutdown, I mean exiting in an elegant way, >>> e.g., we could save history and other important information to disk (so that >>> when the browser restarts, some info does not get lost). >>> >> >> Sure, you could do that if you make sure that the "important information" >> is stored in data structures that have some sort of integrity guarantee, >> which are not manipulated directly by the WebCore/WebKit code. And make sure >> the code that writes those data structures can function without allocating >> additional memory. >> >> But I don't think there's any real advantage to using exception handling >> for this. You could have a function called when out of memory that does this >> work. >> >> Another approach is to save history and other important information as you >> go. So if you run out of memory there's nothing that needs to be done. >> >>-- Darin >> >> ___ >> webkit-dev mailing list >> webkit-dev@lists.webkit.org >> http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev >> > > -- > ___ > webkit-dev mailing > listwebkit-...@lists.webkit.orghttp://lists.webkit.org/mailman/listinfo.cgi/webkit-dev > > > ___ webkit-dev mailing list webkit-dev@lists.webkit.org http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev