Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash: JavaScript heap out of memory #85

Closed
mojodna opened this issue Jul 10, 2018 · 5 comments
Closed

Crash: JavaScript heap out of memory #85

mojodna opened this issue Jul 10, 2018 · 5 comments
Assignees

Comments

@mojodna
Copy link

mojodna commented Jul 10, 2018

Stack trace is from 0.4.1:

<--- JS stacktrace --->

==== JS stack trace =========================================

Security context: 0x223684e25879 <JSObject>
    1: connectEdges(aka connectEdges) [/Users/seth/src/americanredcross/osm-stats-workers/node_modules/martinez-polygon-clipping/dist/martinez.umd.js:~1389] [pc=0x30a376e96f73](this=0x22360a3822d1 <undefined>,sortedEvents=0x223662602451 <JSArray[2801]>,operation=0)
    2: boolean(aka boolean) [/Users/seth/src/americanredcross/osm-stats-workers/node_modules/martinez-polygon-clipping/dist/martinez...

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
 1: node::Abort() [/Users/seth/.nvm/versions/node/v8.11.2/bin/node]
 2: node::FatalException(v8::Isolate*, v8::Local<v8::Value>, v8::Local<v8::Message>) [/Users/seth/.nvm/versions/node/v8.11.2/bin/node]
 3: v8::internal::V8::FatalProcessOutOfMemory(char const*, bool) [/Users/seth/.nvm/versions/node/v8.11.2/bin/node]
 4: v8::internal::Factory::NewUninitializedFixedArray(int) [/Users/seth/.nvm/versions/node/v8.11.2/bin/node]
 5: v8::internal::(anonymous namespace)::ElementsAccessorBase<v8::internal::(anonymous namespace)::FastPackedObjectElementsAccessor, v8::internal::(anonymous namespace)::ElementsKindTraits<(v8::internal::ElementsKind)2> >::GrowCapacity(v8::internal::Handle<v8::internal::JSObject>, unsigned int) [/Users/seth/.nvm/versions/node/v8.11.2/bin/node]
 6: v8::internal::Runtime_GrowArrayElements(int, v8::internal::Object**, v8::internal::Isolate*) [/Users/seth/.nvm/versions/node/v8.11.2/bin/node]
 7: 0x30a376c042fd
 8: 0x30a376e96f73

Geometry being intersected:

{
    "type": "Polygon",
    "coordinates": [
      [
        [
          85.0801983,
          26.9416201
        ],
        [
          85.0801983,
          26.9416201
        ],
        [
          85.0802667,
          26.9416093
        ],
        [
          85.0802667,
          26.9416093
        ],
        [
          85.0801983,
          26.9416201
        ]
      ]
    ]
  }

The larger geometry is China from Natural Earth, so they're both in this gist: https://gist.github.com/mojodna/4a98b2c0bb44e0224a3bce52aebb5000

@izotos
Copy link

izotos commented Aug 2, 2018

Getting the same with:

const {intersection} = require('martinez-polygon-clipping');

const polyA = { "type": "Feature", "properties": {}, "geometry": { "type": "Polygon", "coordinates": [[[180.60987101280907, 22.943242898435663], [280.6098710128091, 22.943242898435663], [280.6098710128091, 62.94324289843566], [180.60987101280907, 62.94324289843566], [180.60987101280907, 22.943242898435663]]] } };
const polyB = { "type": "Feature", "properties": {}, "geometry": { "type": "Polygon", "coordinates": [[[-5.65625, 110.828125], [-7.53125, 202.234375], [366.0625, 202.234375], [356.6875, 65.828125], [260.125, 59.265625], [253.09375, 40.984375], [189.34375, 19.890625], [141.0625, 36.765625], [111.53125, 6.765625], [73.5625, 36.765625], [67.46875, 10.984375], [41.21875, 10.515625], [36.0625, 42.390625], [65.59375, 53.171875], [-5.65625, 110.828125]]] } };

intersection(polyA.geometry.coordinates, polyB.geometry.coordinates);

@w8r w8r self-assigned this Aug 2, 2018
@izotos
Copy link

izotos commented Aug 2, 2018

If it helps, when scaling all coordinates by 0.1 everything works fine. However, in our project we calculate multiple intersections and different scaling factors (both scaling up and scaling down) cause specific cases to error in much the same way.

Here's another failing case, if it is of any relevance (numbers scaled to also appear as proper GeoJSON coordinates):

const {intersection} = require('martinez-polygon-clipping');

const polyA = {"type":"Feature","properties":{},"geometry":{"type":"Polygon","coordinates":[[[3.846028904999335,7.51285572161238],[13.846028904999335,7.51285572161238],[13.846028904999335,11.512855721612379],[3.846028904999335,11.512855721612379],[3.846028904999335,7.51285572161238]]]}};
const polyB = {"type":"Feature","properties":{},"geometry":{"type":"Polygon","coordinates":[[[-0.565625,11.0828125],[-0.753125,20.2234375],[36.60625,20.2234375],[35.66875,6.5828125],[26.0125,5.9265625],[25.309375,4.0984375],[18.934375,1.9890625],[14.10625,3.6765625],[11.153125,0.6765625],[7.35625,3.6765625],[6.746875,1.0984375],[4.121875,1.0515625],[3.60625,4.2390625],[6.559375,5.3171875],[-0.565625,11.0828125]]]}};

intersection(polyA.geometry.coordinates, polyB.geometry.coordinates);

mojodna added a commit to AmericanRedCross/osm-stats-workers that referenced this issue Oct 30, 2018
@rowanwins
Copy link
Collaborator

Resolved in 0.6.0 by #111

@rowanwins
Copy link
Collaborator

Wasn't resolved by #111 - the demo site was a bit dodgy :(

@rowanwins
Copy link
Collaborator

Both resolved by 0.7.3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants