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

A stress test for detecting memory leaks in the infix FFI library. 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 for detecting memory leaks in the infix FFI library.

Copyright (c) 2025 Sanko Robinson

This source code is dual-licensed under the Artistic License 2.0 or the MIT License. You may choose to use this code under the terms of either license.

SPDX-License-Identifier: (Artistic-2.0 OR MIT)

The documentation blocks within this file are licensed under the Creative Commons Attribution 4.0 International License (CC BY 4.0).

SPDX-License-Identifier: CC-BY-4.0

This test is designed to be run under a memory analysis tool like Valgrind or AddressSanitizer. Its purpose is not to verify functional correctness, but to expose memory leaks by performing a large number of allocations and deallocations of all major dynamic FFI objects.

In a tight loop, the test performs the following cycle:

  1. Creates a memory arena.
  2. Builds a deeply nested, complex infix_type graph within the arena.
  3. Generates a forward trampoline using this complex type.
  4. Generates a reverse trampoline (callback) using the same type.
  5. Frees all resources created in that cycle, including the arena itself.

The test is considered successful if it completes without crashing and the memory analysis tool reports ZERO memory leaks.

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:132