Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

String str = null;

 

I forget how much memory a pointer takes.. is it 2 bytes? And 1024 bytes per meg right?

Gamer extraordinaire. Programmer wannabe.
Posted (edited)

Erk. *grabs heart in near heart attack* 4?! :eek: Holy smokes. I thought pointers just stored a 16 bit address... it's 32? That's crazy.

 

EDIT:

 

Err.. and speaking of which..

 

bits -> bytes -> kilobytes -> megs -> gigs

 

I think we were both wrong. Wouldn't it be 8 bits to a byte, 1024 bytes to a kilobyte, 1024 kilobytes to a meg and 1024 megs to a gig. So 1,048,576 bytes to a meg.

 

In which case what I was worried about doesn't matter. I was worried about a large array of reference types taking up a huge amount of memory. But perhaps not;

 

Assuming 4 bytes per reference, that's 524,288 references per meg (1048576 / 4). What I was previously thinking was 256 references per meg (1024 / 4). *blink*

 

I guess I was worrying for nothing. ;)

Edited by wyrd
Gamer extraordinaire. Programmer wannabe.
  • *Experts*
Posted

Oops I dunno what I was thinking....

 

1024^1 bytes = 1 KB

1024^2 bytes = 1 MB

1024^3 bytes = 1 GB

 

etc...

 

 

Also, you could be right about the 16-bit pointers.. I just thought pointers were 32-bit. 65535 bytes available for pointers just doesn't seem reasonable.

Posted
Heh.. well I suppose this is what I get for not keeping the book I used in Assembly class. I'm sure someone will come along and set this whole thing straight. ;)
Gamer extraordinaire. Programmer wannabe.
Posted
Pointers should be specific to the OS architecture. In a 32-bit version of windows a pointer needs to be able to address 4G of ram - therefore 32 bits long.

 

Ah, that would explain it. Gah, now I remember why I thought they were 16 bits. In assembly class we built programs built off of the 16 bit architecture to make things easier.

Gamer extraordinaire. Programmer wannabe.

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...