mapbox / csv2geojson

magically convert csv files to geojson files
http://mapbox.github.io/csv2geojson/
MIT License
362 stars 82 forks source link

JavaScript heap out of memory #55

Open d3netxer opened 7 years ago

d3netxer commented 7 years ago

I'm trying to convert a csv that is 86 mb to geojson using the command line. I installed csv2geojson as a binary. Does anyone know how to fix the following error I'm getting?

FATAL ERROR: CALL_AND_RETRYLAST Allocation failed - JavaScript heap out of memory 1: node::Abort() [node] 2: 0x13647ec [node] 3: v8::Utils::ReportOOMFailure(char const, bool) [node] 4: v8::internal::V8::FatalProcessOutOfMemory(char const, bool) [node] 5: v8::internal::Factory::NewRawTwoByteString(int, v8::internal::PretenureFlag) [node] 6: v8::internal::IncrementalStringBuilder::Extend() [node] 7: v8::internal::JsonStringifier::Result v8::internal::JsonStringifier::Serialize(v8::internal::Handle, bool, v8::internal::Handle) [node] 8: v8::internal::JsonStringifier::SerializeJSReceiverSlow(v8::internal::Handle) [node] 9: v8::internal::JsonStringifier::Result v8::internal::JsonStringifier::Serialize(v8::internal::Handle, bool, v8::internal::Handle) [node] 10: v8::internal::JsonStringifier::Result v8::internal::JsonStringifier::Serialize(v8::internal::Handle, bool, v8::internal::Handle) [node] 11: v8::internal::JsonStringifier::Result v8::internal::JsonStringifier::Serialize(v8::internal::Handle, bool, v8::internal::Handle) [node] 12: v8::internal::JsonStringifier::Result v8::internal::JsonStringifier::Serialize(v8::internal::Handle, bool, v8::internal::Handle) [node] 13: v8::internal::JsonStringifier::Stringify(v8::internal::Handle, v8::internal::Handle, v8::internal::Handle) [node] 14: v8::internal::Builtin_JsonStringify(int, v8::internal::Object*, v8::internal::Isolate) [node] 15: 0xe3c41a8415d

rayterrill commented 5 years ago

Looks like editing the csv2geojson.cmd worked for me on Windows to bump up the amount of memory NodeJS is allowed to use

@IF EXIST "%~dp0\node.exe" (
  "%~dp0\node.exe" --max-old-space-size=8000 "%~dp0\node_modules\csv2geojson\csv2geojson" %*
) ELSE (
  @SETLOCAL
  @SET PATHEXT=%PATHEXT:;.JS;=;%
  node --max-old-space-size=8000 "%~dp0\node_modules\csv2geojson\csv2geojson" %*
)
braco commented 5 years ago

Thanks @rayterrill, you also do this:

NODE_OPTIONS=--max_old_space_size=4096 csv2geojson ...