The Toolkit uses a very simple memory model. For every structure for which you allocate memory using a Toolkit function, you must then use another Toolkit function to release the memory. If you do not observe this simple model, your application will create memory leaks which can result in performance degradations and other problems.
Note: The Vtk_Init function and Vtk_Finish functions allocate resources to the Toolkit. Vtk_Init must be called first, before any other Toolkit function and Vtk_Finish must be called last, after all other functions have completed. Both must only be called once.
The
Table 2 shows the Toolkit functions you can use to allocate and release memory.
Note: In some functions, such as Vtk_ValidationAddCert and Vtk_ValidationAddCertRaw, a pointer to a pointer (**hdl) will allocate the memory without your application specifically calling one of the allocation functions. However, your application will continue to be responsible for releasing the memory allocated; otherwise, memory leaks and other problems will occur.
The Toolkit also provides two other resource allocation functions Vtk_Init and Vtk_Finish. Vtk_Init must be called first, before any other Toolkit function and Vtk_Finish must be called last, after all other functions have completed. Both must be called only once.