24#ifndef MYSQL_DEBUGGING_OOM_TEST_H
25#define MYSQL_DEBUGGING_OOM_TEST_H
64template <std::invocable<mysql::allocators::Memory_resource> Initializer_t,
65 std::invocable Function_t>
67 int calls_until_oom{-1};
69 [&](std::size_t
size) ->
void * {
70 if (calls_until_oom == 0)
return nullptr;
71 if (calls_until_oom > 0) --calls_until_oom;
75 for (
int i = 0;
true; ++i) {
79 if (mysql::utils::call_and_catch(
function) ==
106template <
class Object_t>
108 std::invocable<Object_t &>
auto function) {
112 copy = std::move(Object_t(
object, memory_resource));
114 [&] {
return function(
copy); });
143template <
class Object_t>
145 std::invocable<Object_t &>
auto function) {
150 auto o = Object_t(memory_resource);
151 copy.assign(std::move(o));
153 [[maybe_unused]]
auto ret =
copy.assign(
object);
158 [&] {
return function(
copy); });
Polymorphism-free memory resource class with custom allocator and deallocator functions.
Definition: memory_resource.h:88
#define malloc(A)
Definition: lexyy.cc:914
#define free(A)
Definition: lexyy.cc:915
Class that wraps resources in a polymorphic manner.
void copy(Shards< COUNT > &dst, const Shards< COUNT > &src) noexcept
Copy the counters, overwrite destination.
Definition: ut0counter.h:354
MYSQL_STRINGS_EXPORT void initialize(const char *charset_dir=nullptr, MY_CHARSET_LOADER *loader=nullptr)
Initialize character set/collation library.
Definition: collations.cc:60
Definition: object_lifetime_tracker.h:37
int oom_test_copyable_object(const Object_t &object, std::invocable< Object_t & > auto function)
Repeatedly construct copies of object and call function(copy).
Definition: oom_test.h:107
int oom_test(const Initializer_t &initialize, const Function_t &function)
Repeatedly call function().
Definition: oom_test.h:66
int oom_test_assignable_object(const Object_t &object, std::invocable< Object_t & > auto function)
Repeatedly construct copies of object and call function(copy).
Definition: oom_test.h:144
size_t size(const char *const c)
Definition: base64.h:46