Click here to Skip to main content
15,905,776 members
Home / Discussions / C#
   

C#

 
Questionhow to fire button1_click event while pressing enter key Pin
Shuaib wasif khan18-Sep-08 8:39
Shuaib wasif khan18-Sep-08 8:39 
AnswerRe: how to fire button1_click event while pressing enter key Pin
DaveyM6918-Sep-08 8:56
professionalDaveyM6918-Sep-08 8:56 
AnswerRe: how to fire button1_click event while pressing enter key Pin
Alan N18-Sep-08 8:58
Alan N18-Sep-08 8:58 
QuestionHow to convert an object array to string Pin
soniaiq18-Sep-08 7:32
soniaiq18-Sep-08 7:32 
AnswerRe: How to convert an object array to string Pin
DaveyM6918-Sep-08 7:37
professionalDaveyM6918-Sep-08 7:37 
GeneralRe: How to convert an object array to string Pin
soniaiq18-Sep-08 7:47
soniaiq18-Sep-08 7:47 
GeneralRe: How to convert an object array to string Pin
DaveyM6918-Sep-08 8:34
professionalDaveyM6918-Sep-08 8:34 
GeneralRe: How to convert an object array to string Pin
srabik18-Sep-08 13:18
srabik18-Sep-08 13:18 
AnswerRe: How to convert an object array to string Pin
Paul Conrad18-Sep-08 7:46
professionalPaul Conrad18-Sep-08 7:46 
Question[Message Deleted] Pin
soniaiq18-Sep-08 7:59
soniaiq18-Sep-08 7:59 
AnswerRe: How to convert an object array to string Pin
Paul Conrad18-Sep-08 8:04
professionalPaul Conrad18-Sep-08 8:04 
GeneralRe: How to convert an object array to string Pin
soniaiq18-Sep-08 8:15
soniaiq18-Sep-08 8:15 
GeneralRe: How to convert an object array to string Pin
Paul Conrad18-Sep-08 8:16
professionalPaul Conrad18-Sep-08 8:16 
QuestionStartup Project in VS2005 Pin
Vimalsoft(Pty) Ltd18-Sep-08 6:53
professionalVimalsoft(Pty) Ltd18-Sep-08 6:53 
QuestionSalted hash - Storing Salt In password or a seperate field [modified] Pin
DotNetWWW18-Sep-08 6:41
DotNetWWW18-Sep-08 6:41 
AnswerRe: Salted hash - Storing Salt In password or a seperate field Pin
N a v a n e e t h18-Sep-08 7:12
N a v a n e e t h18-Sep-08 7:12 
GeneralRe: Salted hash - Storing Salt In password or a seperate field Pin
Paul Conrad18-Sep-08 7:48
professionalPaul Conrad18-Sep-08 7:48 
GeneralRe: Salted hash - Storing Salt In password or a seperate field Pin
DotNetWWW18-Sep-08 8:51
DotNetWWW18-Sep-08 8:51 
GeneralRe: Salted hash - Storing Salt In password or a seperate field Pin
N a v a n e e t h18-Sep-08 18:20
N a v a n e e t h18-Sep-08 18:20 
AnswerRe: Salted hash - Storing Salt In password or a seperate field Pin
Paul Conrad18-Sep-08 7:49
professionalPaul Conrad18-Sep-08 7:49 
AnswerRe: Salted hash - Storing Salt In password or a seperate field Pin
Guffa18-Sep-08 9:33
Guffa18-Sep-08 9:33 
QuestionWhere's my (computer's) memory gone? Pin
Rob Philpott18-Sep-08 5:32
Rob Philpott18-Sep-08 5:32 
What's going on here then?

public struct Bobbins
{
	public int X;
}

class Program
{
	static void Main(string[] args)
	{
		Bobbins[] memory = new Bobbins[100000000];
		for (int index = 0; index < memory.Length; index++)
		{
			memory[index] = new Bobbins();
		}
		Console.ReadLine();
	}
}


So here I create an array containing 100 million bobbins structs. I know the for loop isn't necessary but it will be in a minute. 700ms later the program is waiting for me to hit enter and task manager tells me its taking up 400 million bytes of memory. This is good; I like this. My struct contains just an integer of 4 bytes, there's 100 million of them so it all adds up.

Now, if I change bobbins from a struct to a class, I'd expect the memory to double. My class should still be 4 bytes in length and my array now contains 4 byte references to the class (instance). 8 bytes per array element. Infact, 16 seconds after running the application My memory usage is 1.6GB, a total of 16 bytes per element.

Don't get it. Is there some overhead in size on classes?

Regards,
Rob Philpott.

AnswerRe: Where's my (computer's) memory gone? Pin
Mark Salsbery18-Sep-08 6:41
Mark Salsbery18-Sep-08 6:41 
AnswerRe: Where's my (computer's) memory gone? Pin
Alan N18-Sep-08 6:52
Alan N18-Sep-08 6:52 
GeneralRe: Where's my (computer's) memory gone? Pin
Rob Philpott18-Sep-08 6:58
Rob Philpott18-Sep-08 6:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.