How to handle Out-of-Memory in Konqueror?

Josef Weidendorfer Josef.Weidendorfer at gmx.de
Wed Feb 25 13:30:06 GMT 2004


On Wednesday 25 February 2004 11:12, Luciano Montanaro wrote:
> 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...

Yes. But to get summary information, I have to go down recursively to the 
deepest level.

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

It's simple: fsview uses the TreeMap widget which was not supposed to be used 
in this way, but for call hierarchies in KCachegrind. Currently, a lot of 
(painting) attributes are stored separately for every rectangle, which is not 
needed in the case of fsview, and can be avoided.

> > 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.)

Ah, thanks. I didn't know this. Can this generally be used in KDE code, i.e. 
are there old compilers we support and which don't allow for this?

> 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.

Unless you use "ulimit" ;-)

Thanks,
Josef

> > 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