Skip to content

Commit 2911ae6

Browse files
committed
🔪 parcoords memory leak
naive solution, cleaner one coming next, just want to see if this lets our CI tests run
1 parent 6fe2d79 commit 2911ae6

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

src/traces/parcoords/lines.js

+12-13
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ function makePoints(sampleCount, dimensionCount, dimensions, color) {
141141
return points;
142142
}
143143

144-
function makeVecAttr(sampleCount, points, vecIndex) {
144+
function makeVecAttr(regl, sampleCount, points, vecIndex) {
145145

146146
var i, j, k;
147147
var pointPairs = [];
@@ -157,18 +157,16 @@ function makeVecAttr(sampleCount, points, vecIndex) {
157157
}
158158
}
159159

160-
return pointPairs;
160+
return regl.buffer(pointPairs);
161161
}
162162

163-
function makeAttributes(sampleCount, points) {
164-
165-
var vecIndices = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15];
166-
var vectors = vecIndices.map(function(vecIndex) {return makeVecAttr(sampleCount, points, vecIndex);});
163+
function makeAttributes(regl, sampleCount, points) {
167164

168165
var attributes = {};
169-
vectors.forEach(function(v, vecIndex) {
170-
attributes['p' + vecIndex.toString(16)] = v;
171-
});
166+
167+
for(var i = 0; i < 16; i++) {
168+
attributes['p' + i.toString(16)] = makeVecAttr(regl, sampleCount, points, i);
169+
}
172170

173171
return attributes;
174172
}
@@ -206,11 +204,11 @@ module.exports = function(canvasGL, d) {
206204

207205
var panelCount = initialPanels.length;
208206

209-
var points = makePoints(sampleCount, dimensionCount, initialDims, color);
210-
var attributes = makeAttributes(sampleCount, points);
211-
212207
var regl = d.regl;
213208

209+
var points = makePoints(sampleCount, dimensionCount, initialDims, color);
210+
var attributes = makeAttributes(regl, sampleCount, points);
211+
214212
var mask, maskTexture;
215213

216214
var paletteTexture = regl.texture({
@@ -509,7 +507,8 @@ module.exports = function(canvasGL, d) {
509507
function destroy() {
510508
canvasGL.style['pointer-events'] = 'none';
511509
paletteTexture.destroy();
512-
maskTexture.destroy();
510+
if(maskTexture) maskTexture.destroy();
511+
for(var k in attributes) attributes[k].destroy();
513512
}
514513

515514
return {

src/traces/parcoords/parcoords.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ function model(layout, d, i) {
133133
tickFont = trace.tickfont,
134134
rangeFont = trace.rangefont;
135135

136-
var lines = Lib.extendDeep({}, line, {
136+
var lines = Lib.extendDeepNoArrays({}, line, {
137137
color: lineColor.map(domainToUnitScale({
138138
values: lineColor,
139139
range: [line.cmin, line.cmax],
@@ -477,6 +477,7 @@ module.exports = function(root, svg, parcoordsLineLayers, styledData, layout, ca
477477
parcoordsLineLayer
478478
.filter(function(d) {return !!d.viewModel;})
479479
.each(function(d) {
480+
if(d.lineLayer) d.lineLayer.destroy();
480481
d.lineLayer = lineLayerMaker(this, d);
481482
d.viewModel[d.key] = d.lineLayer;
482483
d.lineLayer.render(d.viewModel.panels, !d.context);

0 commit comments

Comments
 (0)