Browse Source

进一步测试内存占用

master
tearshark 6 months ago
parent
commit
f358e07891

+ 5
- 1
benchmark/benchmark_async_mem.cpp View File

@@ -36,8 +36,12 @@ void resumable_main_benchmark_mem(bool wait_key)
}
}
//clang : 平均 256 字节
//clang :
// x64: 平均 256 字节, operator new: size = 48, state size = 32
// x86: 平均 121 字节, operator new: size = 40, state size = 16
//msvc : 平均 304 字节(vs2022,17.7.4)
// x64: 平均 304 字节, operator new: size = 144, state size = 32
// x86: 平均 153 字节, operator new: size = 72, state size = 16
#if LIBRF_TUTORIAL_STAND_ALONE
int main()

+ 1
- 1
include/librf/src/generator.h View File

@@ -221,7 +221,7 @@ namespace librf
char* ptr = _Al.allocate(_Size + _State_size);
char* _Rptr = ptr + _State_size;
#if RESUMEF_DEBUG_COUNTER
std::cout << " generator_promise::new, alloc size=" << (_Size + _State_size) << std::endl;
std::cout << " generator_promise::new, alloc size=" << (_Size + _State_size) << ", state size=" << _State_size << std::endl;
std::cout << " generator_promise::new, alloc ptr=" << (void*)ptr << std::endl;
std::cout << " generator_promise::new, return ptr=" << (void*)_Rptr << std::endl;
#endif

+ 2
- 0
tutorial/test_memory_leak.cpp View File

@@ -17,6 +17,7 @@ void test_memory_leak_event_wait_for()
for (;;)
{
bool val = co_await e.wait_for(1ms);
(void)val;
assert(val == false);
co_await yield();
}
@@ -39,6 +40,7 @@ void test_memory_leak_event_wait_all_for()
for (;;)
{
bool val = co_await event_t::wait_all_for(1ms, e);
(void)val;
assert(val == false);
co_await yield();
}

Loading…
Cancel
Save