infix
A JIT-Powered FFI Library for C
Loading...
Searching...
No Matches
810_memory_stress.c File Reference

A stress test to detect memory leaks under heavy allocation/deallocation cycles. More...

#include "common/double_tap.h"
#include "types.h"
#include <infix/infix.h>
#include <stddef.h>
Include dependency graph for 810_memory_stress.c:

Classes

struct  StressObject
 

Macros

#define DBLTAP_IMPLEMENTATION
 
#define STRESS_ITERATIONS   5000
 

Functions

void dummy_stress_func_fwd (StressObject obj)
 
void dummy_stress_handler_rev (StressObject obj)
 
 subtest ("Memory leak stress test (happy path)")
 

Variables

 TEST
 

Detailed Description

A stress test to detect memory leaks under heavy allocation/deallocation cycles.

This test is not designed to check functional correctness, but rather to ensure the library's memory management is sound. It runs a tight loop that performs a large number of create/destroy cycles for complex forward and reverse trampolines.

In each iteration, it:

  1. Creates a new arena.
  2. Programmatically builds a complex infix_type representing a nested struct with arrays.
  3. Creates a forward trampoline using this type.
  4. Destroys the forward trampoline.
  5. Creates a reverse trampoline using the same type.
  6. Destroys the reverse trampoline.
  7. Destroys the arena.

The test itself only asserts that it completes. Its true purpose is to be run under a memory analysis tool like Valgrind or AddressSanitizer (ASan). A "pass" for this test is a clean report from the memory tool, indicating that no memory was leaked across the thousands of iterations. This is crucial for ensuring the long-term stability of applications that frequently create and destroy trampolines.

Macro Definition Documentation

◆ DBLTAP_IMPLEMENTATION

#define DBLTAP_IMPLEMENTATION

◆ STRESS_ITERATIONS

#define STRESS_ITERATIONS   5000

Function Documentation

◆ dummy_stress_func_fwd()

void dummy_stress_func_fwd ( StressObject  obj)

◆ dummy_stress_handler_rev()

void dummy_stress_handler_rev ( StressObject  obj)

◆ subtest()

subtest ( "Memory leak stress test (happy path)"  )

Variable Documentation

◆ TEST

TEST
Initial value:
{
plan(1)
#define plan(count)
Definition double_tap.h:163