XML Feeds

.

[java-dev] Re: Re: Crash in JitterMatrix.copyMatrixToArray() ?

vboehm at gmx.ch vboehm at gmx.ch
Thu Feb 7 13:37:54 MST 2008


On 06 Feb 2008, at 21:31, Joshua Kit Clayton wrote:
> 
> FWIW, upon further investigation, the memory leak only happens if the  
> array is not matched in size to the matrix size (product of all  
> dimensions). 
> 
> I've fixed this for the next version of Jitter (Max 5 only), so for  
> now, if you want to use these whole matrix at a time methods you'll  
> want to make sure that the sizes match or else you'll mem leak.  
> Otherwise use the recommended vector methods which should not be that  
> much slower if at all.


hmm, interesting. i didn't know about copyArrayToMatrix() - must have slipped in unnoticed somewhere inbetween.
i was using copyArrayToVector() before and it works fine, as you said. 
on a speed comparison however, i was happy to notice that copyArrayToMatrix() is much faster than the vector method - at least in my situation. cpu usage came down half way for a 100x100 matrix (measured with top).

BUT, i can't escape the memory leak even if the array and the matrix match in size!

in the simplified example below, memory is still leaking. where am i going wrong?

any help is welcome, since the speed increase could be crucial to the project i am working on.
thanks,
volker.



import com.cycling74.max.*;
import com.cycling74.jitter.*;

public class LeakerTest extends MaxObject 
{

	int x = 100;
	int y = 100;
	int size = x * y;
	private int[] intArr = new int[size];	
	JitterMatrix mat = new JitterMatrix("mm", 1, "char", x, y);
		
	public LeakerTest (Atom[] args)
	 {
		declareInlets(new int[]{DataTypes.ALL});
		fill(100);
	 }
	
	public void bang() 
	{			
		mat.copyArrayToMatrix( intArr );
	}
	
	public void fill(int k) 
	{
		for(int i=0; i<size; i++)
			intArr[i] = k;
	}
}
-- 
GMX FreeMail: 1 GB Postfach, 5 E-Mail-Adressen, 10 Free SMS.
Alle Infos und kostenlose Anmeldung: http://www.gmx.net/de/go/freemail


More information about the java-dev mailing list