To free or not to free
In my max patch I statically create a bunch of matrices mat1, mat2, mat3 etc. (i.e. I create them in the patcher).
I have a java class which I pass in a name of a matrix (once, or rarely), and the java class acts on that matrix (every frame).
// in the constructor, or when a matrix name is passed in
mat = new JitterMatrix(matrix_name);
// every frame (i.e. on bang) do stuff on mat
My question is, do I need to freepeer the previous matrix it's hanging onto before assigning a new one? i.e.
if(mat != null) mat.freepeer();
mat = new JitterMatrix(matrix_name);
My concern is:
1. if I do freepeer, will it delete the matrix? I don't want to do that because I might have other instances of the class using it. or does it just release it (i.e. drop reference count)
2. if I don't do freepeer, what happens if I accidentally pass it a matrix name which doesn't exist? It will create that matrix? and never get released? creating a memory leak?