Open s-u-s-n opened 8 years ago
hi @s-u-s-n there's a lot going on in this code and it's hard to tell exactly which function could be the problem. could you try stripping down the example code a bit? that is, try removing different pieces from the code you posted until you've isolated the part that causes the memory issue a bit more?
Having similar issues with completely different code. Seems to be worse when resizing window. noLoop seemed to slow down the memory leak though. Was thinking it might be a default browser issue? unsure. But it is incredibly painful.
@s-u-s-n Are you running it on an Intel Iris graphics card?
Hi there,
after about 8 of running the script, I'm running out of application memory. It'll randomly spike from 4 - 16gb and crash my system. Working OSX Yosemite 10.10.5.
Please let me know if it's not a bug in the editor but something in the code.
That's the code:
var y = 100;
var buttonW = 100; var buttonH = 40;
var redX = 50; var redY = 500;
var blueX = 200; var blueY = 500;
var greenX = 350; var greenY = 500;
var blackX = 500; var blackY = 500;
var preAdj = [ 'very', 'slightly', 'incredibly', 'unbelievably', 'unbearably' ]; var line2 = ['cool'];
var reds = ['strawberry', 'red', 'sunset']; var blues = ['nightingale', 'blue', 'depression']; var greens = ['green', 'leaf', 'slimer']; var blacks = ['black'];
function setup() { createCanvas(displayWidth, displayHeight); background(255);
colorMode(HSB, 360, 100, 100); textFont('Helvetica'); textSize(80); fill(360, 0, 100); newColour(6); }
function draw() { buttonGeneral(redX, redY); buttonGeneral(blueX, blueY); buttonGeneral(greenX, greenY); buttonGeneral(blackX, blackY); }
function createLine(words) { var index = floor(random(words.length)); text(words[index], 50, y); y += 90; }
function newColour(colourIndex) {
var colourLookup = [0, 30, 300, 360, 70, 160, 175, 255, 0, 360]; var cIndex = colourIndex;
if (colourIndex === 0){ var ran = random(1); if(ran > 0.5){ cIndex = 0; } else{ cIndex = 2; } }
else{ cIndex === colourIndex; }
var h = random(colourLookup[cIndex], colourLookup[cIndex+1]); var s = (100); var b = (100);
if (colourIndex === 8){ var b = random(25); }
else{ var b = random(40,100); }
background(h, s, b);
createLine(preAdj); createLine(line2); createLine(reds); y = 100; }
function buttonGeneral(xPos, yPos) { noStroke(); if (mouseX > xPos && mouseY > yPos && mouseX < xPos + buttonW && mouseY < yPos + buttonH) { fill(0, 0, 90); } else { fill(0, 0, 100); } rect(xPos, yPos, buttonW, buttonH); }
function mousePressed() {
if (mouseX > redX && mouseY > redY && mouseX < redX + buttonW && mouseY < redY + buttonH) { newColour(0); } else if (mouseX > blueX && mouseY > blueY && mouseX < blueX + buttonW && mouseY < blueY + buttonH) { newColour(4); } else if (mouseX > greenX && mouseY > greenY && mouseX < greenX + buttonW && mouseY < greenY + buttonH) { newColour(6); } else if (mouseX > blackX && mouseY > blackY && mouseX < blackX + buttonW && mouseY < blackY + buttonH) { newColour(8); } }