(I'm using String as an example, but it could be replaced for Object > MB's of memory)
do this quite a lot:
private static String mTempString = "";
private static void SomeMethod()
{
mTempString = "Whatever Result";
}
Now my question is, if I was to write it like so:
private static void SomeMethod()
{
String mTempString = "Whatever Result";
}
and use it in a loop (that is executing hundreds of times a second as an example) would Java know how to manage the memory as example one? Would be memory be of the same efficiently. (Sorry I can't test this myself at the moment)
Which is more memory efficient (disregarding the fact that they are small variables)
--edit--- Found an excellent article here that explains it http://www.cs.berkeley.edu/~jrs/4/lec/08