Skip to content

Commit

Permalink
🔪 parcoords memory leak
Browse files Browse the repository at this point in the history
naive solution, cleaner one coming next, just want to see if this
lets our CI tests run
  • Loading branch information
alexcjohnson committed Mar 16, 2018
1 parent 6fe2d79 commit 2911ae6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
25 changes: 12 additions & 13 deletions src/traces/parcoords/lines.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ function makePoints(sampleCount, dimensionCount, dimensions, color) {
return points;
}

function makeVecAttr(sampleCount, points, vecIndex) {
function makeVecAttr(regl, sampleCount, points, vecIndex) {

var i, j, k;
var pointPairs = [];
Expand All @@ -157,18 +157,16 @@ function makeVecAttr(sampleCount, points, vecIndex) {
}
}

return pointPairs;
return regl.buffer(pointPairs);
}

function makeAttributes(sampleCount, points) {

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

var attributes = {};
vectors.forEach(function(v, vecIndex) {
attributes['p' + vecIndex.toString(16)] = v;
});

for(var i = 0; i < 16; i++) {
attributes['p' + i.toString(16)] = makeVecAttr(regl, sampleCount, points, i);
}

return attributes;
}
Expand Down Expand Up @@ -206,11 +204,11 @@ module.exports = function(canvasGL, d) {

var panelCount = initialPanels.length;

var points = makePoints(sampleCount, dimensionCount, initialDims, color);
var attributes = makeAttributes(sampleCount, points);

var regl = d.regl;

var points = makePoints(sampleCount, dimensionCount, initialDims, color);
var attributes = makeAttributes(regl, sampleCount, points);

var mask, maskTexture;

var paletteTexture = regl.texture({
Expand Down Expand Up @@ -509,7 +507,8 @@ module.exports = function(canvasGL, d) {
function destroy() {
canvasGL.style['pointer-events'] = 'none';
paletteTexture.destroy();
maskTexture.destroy();
if(maskTexture) maskTexture.destroy();
for(var k in attributes) attributes[k].destroy();
}

return {
Expand Down
3 changes: 2 additions & 1 deletion src/traces/parcoords/parcoords.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ function model(layout, d, i) {
tickFont = trace.tickfont,
rangeFont = trace.rangefont;

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

0 comments on commit 2911ae6

Please sign in to comment.