[sr-dev] git:master: malloc_test: new module for testing/debugging memory problems

Andrei Pelinescu-Onciul andrei at iptel.org
Thu Mar 11 21:16:32 CET 2010


Module: sip-router
Branch: master
Commit: 0ff010fa5777a2c9c8ef477079323828e2362781
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=0ff010fa5777a2c9c8ef477079323828e2362781

Author: Andrei Pelinescu-Onciul <andrei at iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei at iptel.org>
Date:   Thu Mar 11 19:38:04 2010 +0100

malloc_test: new module for testing/debugging memory problems

malloc_test is a new module for stressing the memory allocators
and easily simulating out-of-memory conditions or memory leaks.

Implemented RPCs:
mt.mem_alloc size - allocates size bytes
mt.mem_free [size]  - frees at least size bytes. If size is missing
  frees everything allocated by any malloc_test test function.
mt.mem_used  - amount of currently allocated mem. by malloc_test.
mt.mem_rnd_alloc min max total [unit] - allocates total
  <unit> bytes in chunks with the size randomly chosen between min
  and max.  <unit> is optional and can be one of b-bytes, k - kb,
  m - mb, g -gb.
mt.mem_test_start min max total min_int max_int total_time [unit]
  starts a malloc test that will take total_time to execute.
  Memory allocations will be performed at intervals randomly
  chosen between min_int and max_int (in ms). Each allocation will
  have a randomly chosen size between min and max <unit> bytes.
  After total <unit> bytes are allocated, everything is
  released/freed again and the allocations are restarted. The
  total_time is expressed in milliseconds.
  Several tests can be run in the same time.
mt.mem_test_stop id - stops the test identified by id.
mt.mem_test_destroy id - destroys the test identified by id
   (besides stopping it, it also frees all the data, including the
   statistics).
mt.mem_test_destroy_all - destroys all the running or stopped
   tests.
mt.mem_test_list [id] - Prints data about test id (running time,
  total allocations, errors a.s.o.). If id is missing, it will lists
  all the tests.

Script functions:
mt_mem_alloc(size) - equivalent to the mt.mem_alloc RPC.
mt_mem_free(size) - equivalent to the mt.mem_free RPC.

---

 modules/malloc_test/Makefile            |   15 +
 modules/malloc_test/doc/Makefile        |    4 +
 modules/malloc_test/doc/functions.xml   |   56 ++
 modules/malloc_test/doc/malloc_test.xml |   47 ++
 modules/malloc_test/doc/params.xml      |   48 ++
 modules/malloc_test/malloc_test.c       |  887 +++++++++++++++++++++++++++++++
 6 files changed, 1057 insertions(+), 0 deletions(-)

Diff:   http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commitdiff;h=0ff010fa5777a2c9c8ef477079323828e2362781



More information about the sr-dev mailing list