Skip to content
Snippets Groups Projects
  • Vladimir Davydov's avatar
    d394b194
    lua: add malloc info · d394b194
    Vladimir Davydov authored
    This commit adds two new Lua functions:
     - `box.malloc.info()` is a public function that returns the total
       memory usage of internal data structures allocated with `malloc()`.
       This information is extracted from the `malloc_info()` output.
       See the doc bot request for details.
     - `box.malloc.internal.info()` is an internal function that returns
       a parsed XML document returned by `malloc_info()` as is. It isn't
       documented. We may need it to get the detailed information about
       the system memory allocator.
    
    Both functions are useful only on Linux and only if ASAN is disabled
    because otherwise `malloc_info()` is unavailable. On other platforms
    `box.malloc.info()` reports zero memory usage while `internal.info()`
    returns an empty table.
    
    Closes #7311
    
    @TarantoolBot document
    Title: Document `box.malloc.info()`
    
    `box.malloc.info()` is a function that returns a table with two fields:
    
    ```
    tarantool> box.malloc.info()
    ---
    - size: 2498560
      used: 1835726
    ...
    ```
    
    The `used` value is the total amount of memory in bytes allocated by
    Tarantool for internal data structures with [`malloc()`][1].
    
    The `size` value is the total amount of memory in bytes allocated from
    the system by the `malloc()` allocator. It may not be less than `used`.
    
    The function may be used before `box.cfg()` is called.
    
    Currently, the function is available only on Linux. On other systems it
    reports zero memory usage (`{size = 0, used = 0}`).
    
    [1]: https://man7.org/linux/man-pages/man3/malloc.3.html
    
    (cherry picked from commit d34a0cbc)
    d394b194
    History
    lua: add malloc info
    Vladimir Davydov authored
    This commit adds two new Lua functions:
     - `box.malloc.info()` is a public function that returns the total
       memory usage of internal data structures allocated with `malloc()`.
       This information is extracted from the `malloc_info()` output.
       See the doc bot request for details.
     - `box.malloc.internal.info()` is an internal function that returns
       a parsed XML document returned by `malloc_info()` as is. It isn't
       documented. We may need it to get the detailed information about
       the system memory allocator.
    
    Both functions are useful only on Linux and only if ASAN is disabled
    because otherwise `malloc_info()` is unavailable. On other platforms
    `box.malloc.info()` reports zero memory usage while `internal.info()`
    returns an empty table.
    
    Closes #7311
    
    @TarantoolBot document
    Title: Document `box.malloc.info()`
    
    `box.malloc.info()` is a function that returns a table with two fields:
    
    ```
    tarantool> box.malloc.info()
    ---
    - size: 2498560
      used: 1835726
    ...
    ```
    
    The `used` value is the total amount of memory in bytes allocated by
    Tarantool for internal data structures with [`malloc()`][1].
    
    The `size` value is the total amount of memory in bytes allocated from
    the system by the `malloc()` allocator. It may not be less than `used`.
    
    The function may be used before `box.cfg()` is called.
    
    Currently, the function is available only on Linux. On other systems it
    reports zero memory usage (`{size = 0, used = 0}`).
    
    [1]: https://man7.org/linux/man-pages/man3/malloc.3.html
    
    (cherry picked from commit d34a0cbc)