Re: array initilization and memory usage
- From: ge0rge <ge0rge@xxxxxxxxxxx>
- Date: Mon, 26 Jun 2006 10:38:09 +0100
Xavier Tarrago wrote:
<jon23d@xxxxxxxxx> a écrit dans le message de> I don't think so. new Bar[500] will alocate an array of references. Each
news:1151298741.400576.235390@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I'm a little new here, so please bear with me if this sounds like a
goofy
question!...
let's say that I have an class with 15 or so members, each taking up a
fair
amount of space - we'll call this class bars
If I create an array of 400 empty bars objects, but only instantiate
the
first five or so then am I still setting aside the memory for the other
395?
I hope that made sense!
Thanks
> bars[i] = new Bar() will allocate a Bar so you'll end with an array of 400
> references and 5 Bar allocated.
>
Incorrect.
Bar bar[500]; allocates 500 references on the stack - no big space requirement ... but each new Bar() will allocate a Bar object on the heap and the space requirement for a Bar instance.
--
It's not the inital skirt length, it's the upcreep.
.
- Follow-Ups:
- Re: array initilization and memory usage
- From: dsjoblom
- Re: array initilization and memory usage
- From: Frank van Schie
- Re: array initilization and memory usage
- References:
- array initilization and memory usage
- From: jon23d
- Re: array initilization and memory usage
- From: Xavier Tarrago
- array initilization and memory usage
- Prev by Date: Problem with JFormattedTextField - Number field
- Next by Date: Re: How to cause IE to use specific plugin?
- Previous by thread: Re: array initilization and memory usage
- Next by thread: Re: array initilization and memory usage
- Index(es):
Relevant Pages
|