-
Bug
-
Resolution: Fixed
-
P2
-
8u40
-
None
-
b28
-
generic
-
generic
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8056553 | emb-9 | Hannes Wallnoefer | P2 | Resolved | Fixed | master |
JDK-8064132 | 8u45 | Attila Szegedi | P2 | Resolved | Fixed | b01 |
JDK-8055599 | 8u40 | Attila Szegedi | P2 | Closed | Fixed | b04 |
JDK-8070369 | emb-8u47 | Attila Szegedi | P2 | Resolved | Fixed | team |
Adding and removing properties to an object leaks memory. A test program (adapted from node's test/simple/test-event-emitter-memory-leak.js) follows -
var Thread = java.lang.Thread;
var runtime = java.lang.Runtime.getRuntime();
var mb = 1024 * 1024;
var noop = function() {};
var map = {};
runtime.gc();
Thread.sleep(1000);
var before = runtime.freeMemory();
print('before ' + before / mb);
for (var i = 0; i < 16e5; ++i) {
var name = 'a-pretty-long-event-name-zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz-' + i;
map[name] = noop;
delete map[name];
if ((i % 1e5) === 0) {
runtime.gc();
print(' ' + (runtime.freeMemory() - before) / mb);
}
}
runtime.gc();
Thread.sleep(1000);
var after = runtime.freeMemory();
print('after ' + after / mb);
print('leaked ' + ((after - before) / mb));
when run as 'jjs -J-Xms1g -J-Xmx1g leak.js' can be observed to increase its resident size steadily as the program progresses, and prints freeMemory which is seen as steadily decreasing -
before 966.2640838623047
7.783241271972656
44.487510681152344
45.94429016113281
46.042991638183594
45.18035125732422
44.3046875
43.93107604980469
43.05583953857422
42.19343566894531
41.37696075439453
40.98670196533203
40.12110137939453
39.256675720214844
38.39038848876953
37.998321533203125
37.12486267089844
after 1001.1347503662109
leaked 34.87066650390625
var Thread = java.lang.Thread;
var runtime = java.lang.Runtime.getRuntime();
var mb = 1024 * 1024;
var noop = function() {};
var map = {};
runtime.gc();
Thread.sleep(1000);
var before = runtime.freeMemory();
print('before ' + before / mb);
for (var i = 0; i < 16e5; ++i) {
var name = 'a-pretty-long-event-name-zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz-' + i;
map[name] = noop;
delete map[name];
if ((i % 1e5) === 0) {
runtime.gc();
print(' ' + (runtime.freeMemory() - before) / mb);
}
}
runtime.gc();
Thread.sleep(1000);
var after = runtime.freeMemory();
print('after ' + after / mb);
print('leaked ' + ((after - before) / mb));
when run as 'jjs -J-Xms1g -J-Xmx1g leak.js' can be observed to increase its resident size steadily as the program progresses, and prints freeMemory which is seen as steadily decreasing -
before 966.2640838623047
7.783241271972656
44.487510681152344
45.94429016113281
46.042991638183594
45.18035125732422
44.3046875
43.93107604980469
43.05583953857422
42.19343566894531
41.37696075439453
40.98670196533203
40.12110137939453
39.256675720214844
38.39038848876953
37.998321533203125
37.12486267089844
after 1001.1347503662109
leaked 34.87066650390625
- backported by
-
JDK-8056553 nashorn properties leak memory
- Resolved
-
JDK-8064132 nashorn properties leak memory
- Resolved
-
JDK-8070369 nashorn properties leak memory
- Resolved
-
JDK-8055599 nashorn properties leak memory
- Closed
- duplicates
-
JDK-8012247 Re-use of deleted property slots
- Closed