Cirrus Logic CS485 Manual de usuario Pagina 59

  • Descarga
  • Añadir a mis manuales
  • Imprimir
  • Pagina
    / 67
  • Tabla de contenidos
  • MARCADORES
  • Valorado. / 5. Basado en revisión del cliente
Vista de pagina 58
CS485G Spring 2015 59
ii. Every free region has tags and also is linked into a list of
free regions (the link is in the region itself).
iii. To allocate, traverse the free list until a good region is found.
Split it into an allocated region and a free region, adjusting
pointers and tags.
iv. To deallocate, coalesce the region into the ones before and
after if they are free; otherwise, place the region on the free
list.
(b) Slab allocator
i. For every size of allocation, maintain a slab, which is a large
region that can be subdivided into units of the given size.
ii. Each slab also has a header indicating the size and which
units are currently allocated.
iii. To allocate, find the right slab and allocate one of its units.
If the slab is fully allocated or does not exist, start a new
slab.
iv. To deallocate, mark the unit free. If all units are free in a
slab, the entire slab may be deallocated.
(c) Lecture 33, 4/22/2015
(d) Buddy system
57 Garbage collection
1. Explicit free() calls are fragile.
(a) One might forget to free space, leading to a memory leak.
(b) One might free space and keep using it, perhaps through an
alias, leading to memory corruption.
(c) Assuming that newly allocated space is initialized to 0. (If you
need that assumption, use calloc().
(d) Returning a pointer to a local variable.
(e) Freeing a block more than once.
2. Standard alternative: automatic garbage collection.
(a) Part of the run-time library of many languages, like Java, Perl,
Macsyma.
(b) Let allocation continue until there is insufficient free space.
Vista de pagina 58
1 2 ... 54 55 56 57 58 59 60 61 62 63 64 65 66 67

Comentarios a estos manuales

Sin comentarios