How to handle Out-of-Memory in Konqueror?

Luciano Montanaro mikelima at virgilio.it
Wed Feb 25 10:12:49 GMT 2004


On Wednesday 25 February 2004 10:44, Josef Weidendorfer wrote:
> Hi,
> 
> I need your advice. Bug [75775] (konqueror fsview part crashes when viewing a 
> large directory) comes from an out of memory condition. The backtrace shows 
> that the crash is an abort(), triggered by raising an out-of-memory exception 
> in new().
> 
> How to cope with this in a graceful way?
> 
> Of course, I'm thinking about using less memory resources in fsview (currently 
> around 600 Bytes per file). But if someone looks at the root directory of a 
> file server, there will always be the possibility for this out-of-memory 
> condition.

I noticed that fsview was a bit memory hungry... on my home directory, it 
requires memory in the 500MB-1GB range, and that is a bit too much. 
I haven't investigatedmuch on the fsview internals, however maybe you could 
collect full data for the first few directory levels, and show summary 
information for the lower levels in a directory node. This means that the scan 
must be restarted when going deeper in the tree...

By the way, 600 bytes per file are a lot. What kind of data are you collecting?


> 
> First thing: I will have to catch the exception? Or is it enough to check for 
> zero as return value from new() ?

new always returns a valid pointer unless you use nothrow 
(e.g. QString pippo = new(nothrow) QString(1000); will return 0 if the space 
can't be allocated.)
However, Linux, at least, will probably manage to allocate the memory, and it 
will fail when actually trying to access the memory, when it realizes it was 
too optimistic in resource allocation.


> Next: Does it help in this case to free as many objects as possible before 
> showing a notification in message box, or is the process doomed to fail 
> anyway?

See above.

Hope that helps, keep up the good work!

Luciano




More information about the kde-core-devel mailing list