README 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. The malloc_test Module
  2. Andrei Pelinescu-Onciul
  3. iptelorg GmbH
  4. Copyright © 2010 iptelorg GmbH
  5. _________________________________________________________________
  6. Table of Contents
  7. 1. Admin Guide
  8. 1. Overview
  9. 2. Parameters
  10. 2.1. check_content
  11. 3. Functions
  12. 3.1. mt_mem_alloc(size)
  13. 3.2. mt_mem_free()
  14. 4. malloc_test RPC Functions
  15. 4.1. mt.mem_alloc size [unit]
  16. 4.2. mt.mem_free [size] [unit]
  17. 4.3. mt.mem_used [unit]
  18. 4.4. mt.mem_rnd_alloc min max total [unit]
  19. 4.5. mt.mem_test_start min max total min_int max_int
  20. total_time [unit]
  21. 4.6. mt.mem_test_stop id
  22. 4.7. mt.mem_test_destroy id
  23. 4.8. mt.mem_test_destroy_all id
  24. 4.9. mt.mem_test_list [id] [unit]
  25. List of Examples
  26. 1.1. Set check_content in the config file
  27. 1.2. Set check_content at runtime via sercmd
  28. 1.3. men_alloc usage
  29. 1.4. mem_free usage
  30. 1.5. mt.mem_alloc usage
  31. 1.6. mt.mem_free usage
  32. 1.7. mt.mem_used usage
  33. 1.8. mt.mem_rnd_alloc usage
  34. 1.9. mt.mem_test_start usage
  35. 1.10. mt.mem_test_stop usage
  36. 1.11. mt.mem_test_destroy usage
  37. 1.12. mt.mem_test_destroy_all usage
  38. 1.13. mt.mem_test_list usage
  39. Chapter 1. Admin Guide
  40. Table of Contents
  41. 1. Overview
  42. 2. Parameters
  43. 2.1. check_content
  44. 3. Functions
  45. 3.1. mt_mem_alloc(size)
  46. 3.2. mt_mem_free()
  47. 4. malloc_test RPC Functions
  48. 4.1. mt.mem_alloc size [unit]
  49. 4.2. mt.mem_free [size] [unit]
  50. 4.3. mt.mem_used [unit]
  51. 4.4. mt.mem_rnd_alloc min max total [unit]
  52. 4.5. mt.mem_test_start min max total min_int max_int total_time
  53. [unit]
  54. 4.6. mt.mem_test_stop id
  55. 4.7. mt.mem_test_destroy id
  56. 4.8. mt.mem_test_destroy_all id
  57. 4.9. mt.mem_test_list [id] [unit]
  58. 1. Overview
  59. This is a debugging/test module. It implements functions (both script
  60. and rpcs) that can be used to stress the memory allocator or force
  61. memory leaks.
  62. Warning
  63. This module should never be used in a production environment.
  64. 2. Parameters
  65. 2.1. check_content
  66. 2.1. check_content
  67. When doing the tests, check also for the possibility of the memory
  68. being overwritten. When activated, the allocated memory will be filled
  69. with a special pattern, that will be checked on free.
  70. Default: 0 (off).
  71. It can be changed also at runtime, via the rpc interface.
  72. Example 1.1. Set check_content in the config file
  73. modparam("malloc_test", "check_content", 1)
  74. Example 1.2. Set check_content at runtime via sercmd
  75. $ kamcmd cfg.set_now_int malloc_test check_content 1
  76. 3. Functions
  77. 3.1. mt_mem_alloc(size)
  78. 3.2. mt_mem_free()
  79. 3.1. mt_mem_alloc(size)
  80. Allocates size bytes.
  81. Note
  82. This is a debugging function for simulating memory leaks or stressing
  83. the memory allocator. It should not be used in production setups
  84. Example 1.3. men_alloc usage
  85. ...
  86. mem_alloc(1048576); # 1MB
  87. ...
  88. 3.2. mt_mem_free()
  89. Frees all the memory allocated with mem_alloc() up to this point.
  90. Note
  91. This is a debugging function for simulating memory leaks or stressing
  92. the memory allocator. It should not be used in production setups
  93. Example 1.4. mem_free usage
  94. ...
  95. mem_free();
  96. ...
  97. 4. malloc_test RPC Functions
  98. 4.1. mt.mem_alloc size [unit]
  99. 4.2. mt.mem_free [size] [unit]
  100. 4.3. mt.mem_used [unit]
  101. 4.4. mt.mem_rnd_alloc min max total [unit]
  102. 4.5. mt.mem_test_start min max total min_int max_int total_time [unit]
  103. 4.6. mt.mem_test_stop id
  104. 4.7. mt.mem_test_destroy id
  105. 4.8. mt.mem_test_destroy_all id
  106. 4.9. mt.mem_test_list [id] [unit]
  107. 4.1. mt.mem_alloc size [unit]
  108. Allocates the specified number of bytes. unit is optional and can be
  109. one of:
  110. * b - bytes
  111. * k - KB
  112. * m - MB
  113. * g - GB
  114. Example 1.5. mt.mem_alloc usage
  115. $ kamcmd mt.mem_alloc 10 k
  116. 4.2. mt.mem_free [size] [unit]
  117. Frees at least size bytes from the memory allocated by other
  118. malloc_test functions (e.g. mt.mem_alloc).
  119. size is optional. If missing, everything will be freed.
  120. unit is optional and can be one of:
  121. * b - bytes
  122. * k - KB
  123. * m - MB
  124. * g - GB
  125. Example 1.6. mt.mem_free usage
  126. $ kamcmd mt.mem_free 1 m
  127. 4.3. mt.mem_used [unit]
  128. Returns/displays how many bytes are allocated. The default unit is
  129. bytes (for all the possible units see above).
  130. unit is optional and can be one of:
  131. * b - bytes
  132. * k - KB
  133. * m - MB
  134. * g - GB
  135. Example 1.7. mt.mem_used usage
  136. $ kamcmd mt.mem_used
  137. 9221460
  138. 4.4. mt.mem_rnd_alloc min max total [unit]
  139. Allocates total_size memory, in pieces of random size between min ..
  140. max (inclusive). unit is optional and represents the unit for all the
  141. given sizes (see above).
  142. Example 1.8. mt.mem_rnd_alloc usage
  143. $ kamcmd mt.mem_rnd_alloc 1 64 10240 k
  144. 4.5. mt.mem_test_start min max total min_int max_int total_time [unit]
  145. Starts a malloc test that will take total_time to execute. Memory
  146. allocations will be performed at intervals randomly chosen between
  147. min_int and max_int (in ms). Each allocation will have a randomly
  148. chosen size between min and max unit bytes. After total unit bytes are
  149. allocated, everything is released/freed again and the allocations are
  150. restarted. All the times are expressed in milliseconds. unit is
  151. optional and represents the unit for all the given sizes (see above).
  152. Several tests can be run in parallel.
  153. Returns the test id.
  154. Example 1.9. mt.mem_test_start usage
  155. $ kamcmd mt.mem_test_start 15 64 25000 128 1500 3600000 k
  156. 1
  157. 4.6. mt.mem_test_stop id
  158. Stops the test indentified by id.
  159. Example 1.10. mt.mem_test_stop usage
  160. $ kamcmd mt.mem_test_stop 1
  161. 4.7. mt.mem_test_destroy id
  162. Destroys the test indentified by id (besides stopping it, it also
  163. frees all the data, including the statistics).
  164. Example 1.11. mt.mem_test_destroy usage
  165. $ kamcmd mt.mem_test_destroy 1
  166. 4.8. mt.mem_test_destroy_all id
  167. Destroys all the running or stopped tests.
  168. Example 1.12. mt.mem_test_destroy_all usage
  169. $ kamcmd mt.mem_test_destroy_all
  170. 4.9. mt.mem_test_list [id] [unit]
  171. Returns/displays data about the test identified by id, or if no id is
  172. specified, it lists all the tests (running or stopped).
  173. unit is optional. The default is is bytes (for all the possible units
  174. see above).
  175. Example 1.13. mt.mem_test_list usage
  176. $ kamcmd mt.mem_test_list
  177. {
  178. ID : 2
  179. run time (s) : 1471
  180. remaining (s): 2128
  181. allocations : 1749
  182. errors : 24
  183. overflows : 2
  184. total alloc : 69614530
  185. min : 15360
  186. max : 65536
  187. total : 25600000
  188. }
  189. {
  190. ID : 1
  191. run time (s) : 3600
  192. remaining (s): 0
  193. allocations : 4268
  194. errors : 640
  195. overflows : 4
  196. total alloc : 144220713
  197. min : 15360
  198. max : 65536
  199. total : 29696000
  200. }