RE: Out of memory

new topic     » goto parent     » topic index » view thread      » older message » newer message

I had a similar problem recently, not memory (my data file
was much smaller) but speed of loading. Using get() the
file took 26 seconds to load. I thought this grossly
wrong. So I rewrote those parts of my program, without
get(), using "for" and "while" loops writing to disk
and reading from disk and _never_ using recursion. It
worked: the same file loaded in 0.33 seconds. No, not
a typing mistake: from 26 seconds to one third of a
second.

I was not surprised. I had had a similar experience
several years earlier, memory that time. I was having
a team of programmers implement a database of icons
(they used C++). It all went along well when, one day,
they sent me a new implementation, which barfed after
loading just 37 icons -- and I had 64M of RAM, just
about the maximum you could ever hope for in those
days.  So they got a very puzzled "please explain".
After apparently much head scratching the team leader
explained "we have been using  heavily recursive
structures and procedures". That was it, of course.
They rewrote it using iteration instead of recursion
and I ran out of icons before I ran out of memory
again.

I haven't had a look at the source code, but I
guess that get() is -- almost necessarily --
implemented recursively.  It's fine for loading
flat or shallow data, but, as experience shows,
dreadfully inefficient for deeply embedded 
sequences, as you obviously have.

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu