xml-twig 1.3.10 → 1.3.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/samples/memory-test.js +45 -41
package/package.json
CHANGED
package/samples/memory-test.js
CHANGED
|
@@ -2,26 +2,26 @@ const fs = require('fs');
|
|
|
2
2
|
const process = require('process');
|
|
3
3
|
const twig = require('xml-twig');
|
|
4
4
|
|
|
5
|
-
let
|
|
6
|
-
|
|
7
|
-
let parser = twig.createParser([{ tag: '
|
|
8
|
-
|
|
5
|
+
let Entry = 0;
|
|
6
|
+
|
|
7
|
+
let parser = twig.createParser([{ tag: 'Entry', function: EntryHandler }], { method: 'expat' })
|
|
8
|
+
// http://aiweb.cs.washington.edu/research/projects/xmltk/xmldata/data/SwissProt/SwissProt.xml.gz
|
|
9
|
+
let reader = fs.createReadStream(`SwissProt.xml`);
|
|
9
10
|
reader.pipe(parser);
|
|
10
11
|
|
|
11
|
-
function
|
|
12
|
-
|
|
13
|
-
if (
|
|
12
|
+
function EntryHandler(elt) {
|
|
13
|
+
Entry++;
|
|
14
|
+
if (Entry % 10000 === 0) {
|
|
15
|
+
console.log(`Entry ${Entry}`)
|
|
16
|
+
let len = elt.root().writer().toString().length;
|
|
17
|
+
len = Math.round((len / 1024 / 1024 + Number.EPSILON) * 100) / 100;
|
|
18
|
+
console.log(`Size of XML string: ${len} MiB`);
|
|
14
19
|
for (const [key, value] of Object.entries(process.memoryUsage())) {
|
|
15
20
|
console.log(` Memory usage by ${key}, ${Math.round((value / 1024 / 1024 + Number.EPSILON) * 100) / 100} MiB`)
|
|
16
21
|
}
|
|
17
|
-
}
|
|
18
|
-
//elt.purge();
|
|
22
|
+
}
|
|
19
23
|
}
|
|
20
24
|
|
|
21
|
-
reader.on('end', () => {
|
|
22
|
-
console.log(`All done`);
|
|
23
|
-
});
|
|
24
|
-
|
|
25
25
|
|
|
26
26
|
|
|
27
27
|
/*
|
|
@@ -29,44 +29,48 @@ reader.on('end', () => {
|
|
|
29
29
|
* Results
|
|
30
30
|
**********************
|
|
31
31
|
|
|
32
|
+
# Set memory limit to 4GiB for demonstration reasons:
|
|
32
33
|
NODE_OPTIONS=--max-old-space-size=4096
|
|
33
34
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
Memory usage by
|
|
37
|
-
Memory usage by
|
|
38
|
-
Memory usage by
|
|
39
|
-
Memory usage by
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
Memory usage by
|
|
45
|
-
Memory usage by
|
|
35
|
+
Entry 10000
|
|
36
|
+
Size of XML string: 21.08 MiB
|
|
37
|
+
Memory usage by rss, 1897.36 MiB
|
|
38
|
+
Memory usage by heapTotal, 1855.68 MiB
|
|
39
|
+
Memory usage by heapUsed, 1807.43 MiB
|
|
40
|
+
Memory usage by external, 1.13 MiB
|
|
41
|
+
Memory usage by arrayBuffers, 0.7 MiB
|
|
42
|
+
|
|
43
|
+
Entry 20000
|
|
44
|
+
Size of XML string: 40.86 MiB
|
|
45
|
+
Memory usage by rss, 3615.75 MiB
|
|
46
|
+
Memory usage by heapTotal, 3562.62 MiB
|
|
47
|
+
Memory usage by heapUsed, 3482.97 MiB
|
|
48
|
+
Memory usage by external, 0.63 MiB
|
|
49
|
+
Memory usage by arrayBuffers, 0.2 MiB
|
|
46
50
|
|
|
47
51
|
<--- Last few GCs --->
|
|
48
52
|
|
|
49
|
-
[
|
|
50
|
-
[
|
|
53
|
+
[18648:000001F930FC8F90] 13906 ms: Scavenge 4047.7 (4123.2) -> 4047.3 (4133.7) MB, 3.4 / 0.0 ms (average mu = 0.332, current mu = 0.185) allocation failure;
|
|
54
|
+
[18648:000001F930FC8F90] 13916 ms: Scavenge 4054.1 (4133.7) -> 4053.8 (4135.2) MB, 4.0 / 0.0 ms (average mu = 0.332, current mu = 0.185) allocation failure;
|
|
55
|
+
[18648:000001F930FC8F90] 13925 ms: Scavenge 4055.1 (4135.2) -> 4054.3 (4156.2) MB, 8.3 / 0.0 ms (average mu = 0.332, current mu = 0.185) allocation failure;
|
|
51
56
|
|
|
52
57
|
|
|
53
58
|
<--- JS stacktrace --->
|
|
54
59
|
|
|
55
60
|
FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory
|
|
56
|
-
1:
|
|
57
|
-
2:
|
|
58
|
-
3:
|
|
59
|
-
4:
|
|
60
|
-
5:
|
|
61
|
-
6:
|
|
62
|
-
7:
|
|
63
|
-
8:
|
|
64
|
-
9:
|
|
65
|
-
10:
|
|
66
|
-
11:
|
|
67
|
-
12:
|
|
68
|
-
13:
|
|
69
|
-
|
|
61
|
+
1: 00007FF604481C7F node_api_throw_syntax_error+175855
|
|
62
|
+
2: 00007FF604406476 EVP_MD_meth_get_input_blocksize+59654
|
|
63
|
+
3: 00007FF604408160 EVP_MD_meth_get_input_blocksize+67056
|
|
64
|
+
4: 00007FF604EB0434 v8::Isolate::ReportExternalAllocationLimitReached+116
|
|
65
|
+
5: 00007FF604E9B7C2 v8::Isolate::Exit+674
|
|
66
|
+
6: 00007FF604D1D65C v8::internal::EmbedderStackStateScope::ExplicitScopeForTesting+124
|
|
67
|
+
7: 00007FF604D1A87B v8::internal::Heap::CollectGarbage+3963
|
|
68
|
+
8: 00007FF604D30AB3 v8::internal::HeapAllocator::AllocateRawWithLightRetrySlowPath+2099
|
|
69
|
+
9: 00007FF604D3135D v8::internal::HeapAllocator::AllocateRawWithRetryOrFailSlowPath+93
|
|
70
|
+
10: 00007FF604D40B20 v8::internal::Factory::NewFillerObject+816
|
|
71
|
+
11: 00007FF604A31565 v8::internal::DateCache::Weekday+1349
|
|
72
|
+
12: 00007FF604F4D961 v8::internal::SetupIsolateDelegate::SetupHeap+558193
|
|
73
|
+
13: 00007FF5B03D1532
|
|
70
74
|
|
|
71
75
|
*/
|
|
72
76
|
|