Diesel Posted September 7, 2004 Posted September 7, 2004 int[] intArray; intArray = new int[5]; intArray.SetValue(1, 0); intArray.SetValue(1, 1); intArray.SetValue(1, 2); intArray.SetValue(1, 3); intArray.SetValue(1, 4); intArray = new int[0]; What happens to the data that was previously there? Can the gc pick it up? Should I care? Quote
Administrators PlausiblyDamp Posted September 8, 2004 Administrators Posted September 8, 2004 Once intArray points to the new array as long as no other variable referes to the old array then the GC will be able to collect the memory. Note that it will not be immediatly collected though, just whenever the GC kicks in next. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
BlackStone Posted September 8, 2004 Posted September 8, 2004 Just once were on the subject on arrays in memory, are integers in the array boxed? Is there a decrease in performance because of this? Quote "For every complex problem, there is a solution that is simple, neat, and wrong." - H. L. Mencken
*Experts* Nerseus Posted September 9, 2004 *Experts* Posted September 9, 2004 They should not be boxed because the array is an int array. If you stored them in an object array then they would be. Same is true for an ArrayList, which stores objects only. I wouldn't worry too much about boxing/unboxing. True, there is a performance "hit" but I've yet to see it as an issue in any performance testing I've done. -ner Quote "I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.