67_pdfsam_cs2022 - Garbage collection Java uses a technique...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Garbage collection Java uses a technique called garbage collection The JVM occasionally scans for heap space no longer in use It frees objects not pointed to by any reference This garbage collector is run as a background thread Java was specifically designed for garbage collection The JVM can figure out whether an object is in use This isn’t possible in C because of pointer arithmetic
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Pointers make garbage collection difficult or impossible It’s very difficult to determine whether memory is still being used Java’s references are a restricted form of pointers that don’t allow arithmetic, just because of this issue There are garbage collecting libraries for C, but they aren’t guaranteed to work with any program char *s = (char *) malloc(1024); s = s - 10000; // nothing points to the allocated memory // region. Could it be garbage collected? s = s + 10000;
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/10/2010 for the course CS 2022 at Cornell University (Engineering School).

Page1 / 6

67_pdfsam_cs2022 - Garbage collection Java uses a technique...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online