blender-guardedalloc.txt 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. MEMORY MANAGEMENT IN BLENDER (guardedalloc)
  2. -------------------------------------------
  3. NOTE: This file does not cover memutil and smart pointers and reference counted
  4. garbage collection, which are contained in the memutil module.
  5. Blender takes care of dynamic memory allocation using a set of own functions
  6. which are recognizable through their MEM_ prefix. All memory allocation and
  7. deallocation in blender is done through these functions.
  8. The following functions are available through MEM_guardedalloc.h:
  9. For normal operation:
  10. ---------------------
  11. void *MEM_[mc]allocN(unsigned int len, char * str);
  12. - nearest ANSI counterpart: malloc()
  13. - str must be a static string describing the memory block (used for debugging
  14. memory management problems)
  15. - returns a memory block of length len
  16. - MEM_callocN clears the memory block to 0
  17. void *MEM_dupallocN(void *vmemh);
  18. - nearest ANSI counterpart: combination malloc() and memcpy()
  19. - returns a pointer to a copy of the given memory area
  20. short MEM_freeN(void *vmemh);
  21. - nearest ANSI counterpart: free()
  22. - frees the memory area given by the pointer
  23. - returns 0 on success and !=0 on error
  24. int MEM_allocN_len(void *vmemh);
  25. - nearest ANSI counterpart: none known
  26. - returns the length of the given memory area
  27. For debugging:
  28. --------------
  29. void MEM_set_error_stream(FILE*);
  30. - this sets the file the memory manager should use to output debugging messages
  31. - if the parameter is NULL the messages are suppressed
  32. - default is that messages are suppressed
  33. void MEM_printmemlist(void);
  34. - if err_stream is set by MEM_set_error_stream() this function dumps a list of all
  35. currently allocated memory blocks with length and name to the stream
  36. bool MEM_consistency_check(void);
  37. - this function tests if the internal structures of the memory manager are intact
  38. - returns 0 on success and !=0 on error