01.12.2014 Views

here in PDF - Parasol Laboratory, Department of Computer Science ...

here in PDF - Parasol Laboratory, Department of Computer Science ...

here in PDF - Parasol Laboratory, Department of Computer Science ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

CPSC 211 Data Structures & Implementations (c) Texas A&M University [ 13 ]<br />

Stack vs. Heap<br />

Memory used by an execut<strong>in</strong>g program is partitioned:<br />

the stack:<br />

– When a method beg<strong>in</strong>s execut<strong>in</strong>g, a piece <strong>of</strong> the<br />

stack (stack frame) is devoted to it.<br />

– T<strong>here</strong> is an entry <strong>in</strong> the stack frame for<br />

<br />

<br />

<br />

– For variables <strong>of</strong> primitive type, the data itself is<br />

stored<br />

For variables <strong>of</strong> object type,<br />

– When the method f<strong>in</strong>ishes, the method’s stack frame<br />

is<br />

the heap: Dynamically allocated memory goes <strong>here</strong>,<br />

<strong>in</strong>clud<strong>in</strong>g the actual data for objects. Lifetime is

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!