13 Commits

Author SHA1 Message Date
rationalcoder
710533975e Fix out-of-band allocations in dynamic arenas 2025-09-16 16:31:10 -05:00
Feoramund
58f32cd690 Fix Linux-specific optimized test failure
The stack was not aligned as expected for `buddy_allocator_init` when
`-o:speed` was enabled, making this a test failure that only appeared
with optimizations enabled.

The data is now aligned specifically, as it should be.
2025-07-22 10:40:16 -04:00
Feoramund
0b2cf9a4ca Add a tiny sanity test for core:mem allocators 2025-06-15 14:29:30 -04:00
Jeroen van Rijn
0fc141db5d core:mem/tlsf: Add early-out in OOM logic
This implementation doesn't allow for out-of-band allocations to be passed through, as it's not designed to
track those. Nor is it able to signal those allocations then need to be freed on the backing allocator,
as opposed to regular allocations handled for you when you `destroy` the TLSF instance.

So if we're asked for more than we're configured to grow by, we can fail with an OOM error early, without adding a new pool.
2025-04-14 20:40:05 +02:00
Jeroen van Rijn
beee27dec0 Allow core:mem/tlsf to automatically add new pools.
New features:
- If TLSF can't service an allocation made on it, and it's initialized with `new_pool_size` > 0, it will ask the backing allocator for additional memory.

- `estimate_pool_size` can tell you what size your initial (and `new_pool_size`) ought to be if you want to make `count` allocations of `size` and `alignment`, or in its other form, how much backing memory is needed for `count` allocations of `type` and its corresponding size and alignment.
2025-04-14 19:49:55 +02:00
Jeroen van Rijn
7088284ff4 Refactor core:mem/tlsf, add free_all support.
TODO: Allow the TLSF allocator to add additional pools when it would ordinarily OOM
      by calling its backing allocator.
2025-04-14 17:13:27 +02:00
Laytan Laats
ae0f69fbe2 cleanup test arenas 2025-02-12 19:13:16 +01:00
Laytan Laats
7df5be2131 fix wrong out of memory in edge cases, just try allocate from block for one source of truth 2025-02-12 19:09:21 +01:00
flysand7
167ced8ad1 [mem]: Don't use named params for dynamic pool in tests 2024-09-08 18:52:55 +11:00
Jeroen van Rijn
4d27898418 Use test runner's own tracking allocator. 2024-08-08 20:58:25 +02:00
Jeroen van Rijn
80d1e1ba82 Allow testing for intentional leaks in test runner
Adds `expect_leak_or_bad_free :: proc(t: ^T, client_test: proc(t: ^T), verifier: Memory_Verifier_Proc)`.

It sets up its own `Tracking_Allocator`, runs the `client_test`, and then calls the `verifier` procedure.
The verifier can then inspect the contents of the tracking allocator and call `testing.expect*` as sensible for the test in question.

Any allocations are then cleared so that the test runner doesn't itself complain about leaks.

Additionally, `ODIN_TEST_LOG_LEVEL_MEMORY` has been added as a define to set the severity of the test runner's memory tracker. You can use `-define:ODIN_TEST_LOG_LEVEL_MEMORY=error` to make tests fail rather than warn if leaks or bad frees have been found.
2024-08-08 20:41:32 +02:00
DerTee
a76f9a70d5 add test for allocator mem.Dynamic_Pool
this test currently fails because of bug #3692
2024-07-03 22:13:20 +02:00
Jeroen van Rijn
72f6b5479d Fix fls_uint 2024-06-06 14:42:19 +02:00