Page 66 of 66
General Advice (cont)
Deallocate Resources You Allocated:
- Anything allocated in _init(9E) should be deallocated
in _fini(9E)
- Normally things allocated in attach(9E) should be deallocated
in detach(9E)
- Normally things allocated in open(9E) should be deallocated
in close(9E)
- probe(9E) must deallocate anything it allocates
- A call to mutex_destroy(9F) should match a call to
mutex_init(9F)
- A call to cv_destroy(9F) should match a call to cv_init(9F)
- A call to ddi_remove_intr(9F) should match a call to
ddi_add_intr(9F)
- Memory that was allocated or mapped should be freed
or unmapped
- etc...
- Failure to properly deallocate resources results in "memory
leaks"
- Memory leaks can result in degraded system performance
over time
FIRST PREVIOUS
NEXT LAST
CONTENTS
Return to White Papers
|