Re: array allocaton size
From: Victor Bazarov (v.Abazarov_at_comAcast.net)
Date: 06/25/04
- Next message: John Cochran: "Re: bitcounting on 30000+ bits, but not byte aligned"
- Previous message: Daniel Blankensteiner: "Re: Libraries in C++"
- In reply to: Keith S.: "array allocaton size"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 25 Jun 2004 14:11:26 GMT
Keith S. wrote:
> This may be a dumb question, but I've searched the FAQ
> and can't find an obvious answer...
>
> Let's say I have a class e.g.
>
> class fred
> {
> public:
>
> int x;
> int y;
> };
>
> then I create an array of fred:
>
> freds = new fred[2];
>
> Now, I'd expect to have allocated 8 bytes * 2 i.e. 16 bytes.
Is that 'sizeof(fred) * 2'?
> However, if I step through the code with a debugger I see
> that operator new is getting called with a size of 20 bytes.
> Why is this? What's the extra 4 bytes coming from?
Some compiler-/OS-specific dynamic memory allocation information
is stored there, perhaps. Why do you care?
> The platform is VC++ .NET 2003 in debug mode if it makes any
> difference...
You might want to ask in microsoft.public.vc.language if you need
to know more about VC++'s memory manager.
V
- Next message: John Cochran: "Re: bitcounting on 30000+ bits, but not byte aligned"
- Previous message: Daniel Blankensteiner: "Re: Libraries in C++"
- In reply to: Keith S.: "array allocaton size"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|