"JavaScript heap out of memory" error unless positions initialized
Closed this issue · 0 comments
jamesscottbrown commented
I have tried applying this layout to a very small network (3 nodes, 2 edges) using the node REPL. However, this hung for ~40s then gave the error FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory
.
However, this is avoided by either first applying a different layout (e.g., circle
), or by setting the animate
option to true
.
$ node
Welcome to Node.js v16.13.0.
Type ".help" for more information.
> const cytoscape = require('cytoscape')
undefined
> const euler = require('cytoscape-euler');
undefined
> cytoscape.use(euler)
[Function: cytoscape] {
use: [Function (anonymous)],
warnings: [Function (anonymous)],
version: '3.20.0',
Stylesheet: [Function: Stylesheet],
stylesheet: [Function: Stylesheet]
}
> const nodes = [
... {"id": "Alice"},
... {"id": "Bob"},
... {"id": "Carol"}
... ];
undefined
>
> const links = [
... {"source": "Alice", "target": "Bob"}, // Alice → Bob
... {"source": "Bob", "target": "Carol"} // Bob → Carol
... ];
undefined
>
> const elements = [
... ...nodes.map(n => ({data: n})),
... ...links.map(n => ({data: n}))
... ];
undefined
>
> let cy = cytoscape({elements});
undefined
> cy.layout({name: 'euler', animate: false}).run();
<--- Last few GCs --->
[16008:0x5b44120] 102577 ms: Scavenge 4040.9 (4112.5) -> 4040.6 (4123.8) MB, 9.4 / 0.0 ms (average mu = 0.165, current mu = 0.122) allocation failure
[16008:0x5b44120] 102594 ms: Scavenge 4048.4 (4123.8) -> 4049.2 (4124.8) MB, 9.5 / 0.0 ms (average mu = 0.165, current mu = 0.122) allocation failure
[16008:0x5b44120] 104133 ms: Scavenge 4049.2 (4124.8) -> 4048.3 (4147.0) MB, 1539.4 / 0.0 ms (average mu = 0.165, current mu = 0.122) allocation failure
<--- JS stacktrace --->
FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory
1: 0xb02ec0 node::Abort() [node]
2: 0xa181fb node::FatalError(char const*, char const*) [node]
3: 0xced88e v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [node]
4: 0xcedc07 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [node]
5: 0xea5ea5 [node]
6: 0xeb557d v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [node]
7: 0xeb827e v8::internal::Heap::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [node]
8: 0xe796aa v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationType, v8::internal::AllocationOrigin) [node]
9: 0x11f2e86 v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [node]
10: 0x15e7879 [node]
Aborted (core dumped)
Showing just the code:
const cytoscape = require('cytoscape')
const euler = require('cytoscape-euler')
const nodes = [
{"id": "Alice"},
{"id": "Bob"},
{"id": "Carol"}
];
const links = [
{"source": "Alice", "target": "Bob"}, // Alice → Bob
{"source": "Bob", "target": "Carol"} // Bob → Carol
];
const elements = [
...nodes.map(n => ({data: n})),
...links.map(n => ({data: n}))
];
cytoscape.use(euler);
let cy = cytoscape({ elements });
cy.layout({name: 'euler', animate: false}).run();