[OSM-dev] Freemap renderer: memory problems - one for the SQL gurus?

Nick Whitelegg nick at hogweed.org
Thu Oct 5 22:59:56 BST 2006


Am making modifications to my Freemap renderer at the moment, and having 
enormous trouble trying to stop it reporting running out of memory when 
rendering tiles with lots of ways in them in urban areas.

The original algorithm went something like this:

Read all nodes into memory from d/b
Read all segments into memory from d/b
Read all ways into memory from d/b, and also store the style (line colour etc) 
of *each* way in memory

I've now changed it to the following, which I thought would eliminate the 
problems:

Read in all nodes into memory from d/b
Read in all segments into memory from d/b

Connect to database
Query database for all ways
For each way
    Get its style (line colour, etc)
    Draw way
Next

Note that this version never stores more than one way, or its style, in memory 
at once.

However, this does *not* resolve the memory issues; indeed it does not appear 
to make one jot of difference. They are as bad as before (i.e. the tiles 
which failed before still fail now). Whatever is using up so much memory *is* 
related to ways, it's not related to storing all the nodes and segments in 
memory - as if I comment out the way stuff, I get no problems even in densely 
populated urban areas.

I really can't see what's using up so much memory. I had similar problem when 
I wrote a PHP-based SAX (i.e. should be light on memory) planet parser. Is it 
some problem with PHP? Or is there something in my sql which could be 
improved? (the code is in subversion under freemap, freemap.php then 
draw_ways() draws the ways)

Anyone got any ideas? An SQL issue or an inherent issue with PHP?
Incidentally is 8MB a reasonable upper memory limit for an apache/php process 
or could it be safely upped somewhat?

Thanks,
Nick




More information about the dev mailing list