I'm experiencing what appears to be memory issues when setting my sketch up on a vastly superior machine to the one I wrote it on.
I wondered if anyone could shed any light on why this may be?
The specific error is:
Waited 5000ms for <510dc2, 15e3dc4>[count 2, qsz o, owner <AWT-EventQueue-0>] - <Animation Thread>
This doesn't always occur, 50% of the time the sketch runs fine. Another thread suggested this may be to do with high amounts of calculations performed in setup, so I've copied my function below:
The original machine is running OSX 10.8.3, and is a 2.26GHz dual core Processor with 8Gb RAM. The second machine is a 3.4GHz core i7 with 16Gb RAM. Processing on both machines has the max RAM set at 2048Mb in preferences.
setup either loads an oni file (these are pretty big, 1-2Gb), or initialises the kinect.
I'd like to be able to fix it, but more importantly understand what could be affecting the performance of the faster computer... cheers!
I'm trying to update the value of a hashmap key dynamically, in order to get the minimum and maximum values within a JSON object containing timbre information for an audio file.
There are 2 maps, to contain maximum and minimum values for each of the 12 timbres in the JSON file.
The map keys (t1, t2, tn) are initially given a value of 0. I want to update these values in both the maximum and minimum maps each time they exceed or go under whatever is their current value.
In the example below,
println("a: "+maxTimbres.get("t"+j)); returns (0), whereas
println("b: "+maxTimbres.get("t"+j)); returns the value that should have been updated in the hashmap.
How do I need to structure my code in order to achieve this? Is there a better way to approach it? I looked into dynamically creating variables but this seemed very complex in java.
thanks!
// create HashMap to store max and min values for each of the 12 timbres
Not too sure of my terms here as I'm a relative newbie, but I've just discovered I need to use an ArrayList instead of an array in order to add and remove elements at runtime, so I've sussed out how to do that:
The problem is that when I call up the particles from the arrayList (as opposed to the regular multidimensional array I had used previously, they seem to have lost the values they were instantiated with, and odd things happen with their local geometry.
Could anyone help me understand why this would be, and what the best way to get around it is? I'll copy in below my previous example, and the particle class (from the form & code book). Thanks
int pSystems = 4;
int pDensity = 100;
Particle[][] particles = new Particle[pSystems][pDensity];
boolean saving = false;
void setup() {
size(1024, 768);
smooth();
for (int i = 0; i < pSystems; i++) {
for (int j = 0; j < pDensity; j++) {
particles[i][j] = new Particle(new PVector(100*i, 100*i));
Which I can't seem to locate in the new documentation. Here is the context:
import geomerative.*;
PFont font;
RFont f; RGroup grp; RShape s;
float len; float angle; float pos;
//------------------------ Runtime properties ---------------------------------- // Save each frame boolean SAVEVIDEO = false; boolean SAVEFRAME = true; boolean APPLICATION = false;
String DEFAULTAPPLETRENDERER = JAVA2D; int DEFAULTAPPLETWIDTH =600; int DEFAULTAPPLETHEIGHT =600;
String DEFAULTAPPLICRENDERER = OPENGL; int DEFAULTAPPLICWIDTH = 600; int DEFAULTAPPLICHEIGHT =600; //------------------------------------------------------------------------------
// The error range for the tangent position and angle float ANGLEERROR = 0.1; float POINTERROR = 0;
// The length variation of the tangnet // -> 500: sketchy, blueprint // -> 150: light blueprint // -> 2000: mystic float LENGTHTANGENT = 30;
// The initial text String STRNG = "S";
String FONT = "arial.ttf";
// The alpha value of the lines int ALPHAVALUE = 2;
// The velocity of the calligraphy int VELOCITY = 1;
int MARGIN = 1;
String newString = "";
void setup(){
int w = DEFAULTAPPLICWIDTH, h = DEFAULTAPPLICHEIGHT; String r = DEFAULTAPPLICRENDERER;
if(!APPLICATION){ // Specify the widtha and height at runtime w = int(param("width")); h = int(param("height")); r = (String)param("renderer");
// (String) will return null if param("renderer") doesn't exist if (r != OPENGL && r != P3D && r != JAVA2D && r != P2D) { r = DEFAULTAPPLETRENDERER; } // int() will return 0 if param("width") doesn't exist if (w <= 0) { w = DEFAULTAPPLETWIDTH; } // int() will return 0 if param("height") doesn't exist if (h <= 0) { h = DEFAULTAPPLETHEIGHT; } }
size(w,h,r); background(255); frameRate(25);
LENGTHTANGENT = LENGTHTANGENT * width/800F;
try{ smooth(); }catch(Exception e){}
noFill();
stroke(0, 0, 0,80); noFill();
//f = new RFont(this, FONT, 372, RFont.CENTER); RG.init(this); f = new RFont(FONT, 372, RFont.CENTER);
initialize(); }
void draw(){ pushMatrix(); translate(width/2,height/2); // Draw very low alpha and long tangents on random points of each letters for(int i=0;i<grp.countElements();i++){ s = (RShape)(grp.elements[i]);