Created
March 2, 2012 23:43
-
-
Save springmeyer/1962456 to your computer and use it in GitHub Desktop.
patch to work kinda around mem issues
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff -u src/tilemill/node_modules/tilelive-mapnik/lib//mapnik.js /usr/share/tilemill/node_modules/tilelive-mapnik/lib//mapnik.js | |
--- src/tilemill/node_modules/tilelive-mapnik/lib//mapnik.js 2012-03-02 12:40:05.000000000 -0500 | |
+++ /usr/share/tilemill/node_modules/tilelive-mapnik/lib//mapnik.js 2012-03-01 21:56:50.000000000 -0500 | |
@@ -8,7 +8,7 @@ | |
var Pool = require('generic-pool').Pool; | |
var LockingCache = require('./lockingcache'); | |
var sm = new (require('sphericalmercator')); | |
- | |
+var os = require('os'); | |
var cache = {}; | |
// Increase number of threads to 1.5x the number of logical CPUs. | |
@@ -208,7 +208,15 @@ | |
create: function(callback) { | |
var map = new mapnik.Map(256, 256); | |
map.bufferSize = source._uri.query.bufferSize; | |
- map.fromString(xml, { | |
+ console.log('creating map'); | |
+ console.log('free: ' + os.freemem() + ' load: ' + os.loadavg() + ' % free: ' + os.freemem()/os.totalmem()*100); | |
+ try { | |
+ map.fromStringSync(xml,{strict:true,base:source._base+'/'}); | |
+ } catch (err) { | |
+ return callback(err); | |
+ } | |
+ callback(null,map); | |
+ /*map.fromString(xml, { | |
strict: false, | |
base: source._base + '/' | |
}, function(err, map) { | |
@@ -216,13 +224,15 @@ | |
// Wrap zoomAll() with a try/catch and don't bail on error. | |
// Certain layers/projections seem to cause an error here that | |
// need not be fatal. | |
- try { | |
- map.zoomAll(); | |
- } catch(e) {}; | |
+ //try { | |
+ // map.zoomAll(); | |
+ //} catch(e) {}; | |
callback(null, map); | |
}); | |
+ */ | |
}, | |
destroy: function(map) { | |
+ console.log('clearing'); | |
map.clear(); | |
delete map; | |
}, | |
diff -u src/tilemill/node_modules/tilelive-mapnik/lib//render.js /usr/share/tilemill/node_modules/tilelive-mapnik/lib//render.js | |
--- src/tilemill/node_modules/tilelive-mapnik/lib//render.js 2012-03-02 12:40:05.000000000 -0500 | |
+++ /usr/share/tilemill/node_modules/tilelive-mapnik/lib//render.js 2012-03-01 22:30:39.000000000 -0500 | |
@@ -4,6 +4,7 @@ | |
var MapnikSource = require('./mapnik'); | |
var solidCache = {}; | |
+var os = require('os'); | |
var EARTH_RADIUS = 6378137; | |
var EARTH_DIAMETER = EARTH_RADIUS * Math.PI; | |
@@ -89,9 +90,16 @@ | |
// Add stats. | |
options.source._stats.total++; | |
- if (solid !== false) options.source._stats.solid++; | |
+ if (solid !== false) { | |
+ options.source._stats.solid++; | |
+ console.log(options.source._stats.solid); | |
+ } | |
if (solid !== false && image.painted()) options.source._stats.solidPainted++; | |
- | |
+ if (options.source._stats.solid%100 == 0) { | |
+ console.log('start...forcing gc!'); | |
+ while(!mapnik.gc()) {} | |
+ console.log('end.....forcing gc!'); | |
+ } | |
// If solid and image buffer is cached skip image encoding. | |
if (solid && solidCache[solid]) return callback(null, solidCache[solid]); | |
@@ -118,6 +126,7 @@ | |
// Calculate bbox from xyz, respecting metatile settings. | |
var meta = calculateMetatile(options); | |
+ console.log('free: ' + os.freemem() + ' load: ' + os.loadavg() + ' % free: ' + os.freemem()/os.totalmem()*100); | |
// Set default options. | |
if (options.format === 'utf') { | |
var interactivity = source._mml.interactivity; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment