Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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?

Posted
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?
"For every complex problem, there is a solution that is simple, neat, and wrong." - H. L. Mencken
  • *Experts*
Posted

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

"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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...