Category : allocation

const size_t size = 10000000; using T = unsigned short[]; vector<unique_ptr<T>> v; v.resize(size); for (size_t n = 0; n != size ; ++n) { v[n] = make_unique<T>(3); for (int i = 0; i!= 3; ++i) v[n][i] = rand(); } I want to measure how much memory it uses. What I expect: 10.000.000*(8+2*3) = 140.000.000 bytes. ..

Read more

I’m trying to use tracy (https://github.com/wolfpld/tracy) with CUDA With tracy, to measure memory usage you override operator new and operator delete like this: void* operator new(std::size_t count) { auto ptr = malloc(count); TracyAlloc(ptr, count); return ptr; } void operator delete(void* ptr) noexcept { TracyFree(ptr); free(ptr); } But when trying to use these with CUDA code ..

Read more

Why allocate() and deallocate() has not been called when using self-defined allocator with std::string? Here is the code snippet for demo(https://coliru.stacked-crooked.com/a/bcec030e8693f7ae): #include <cstring> #include <iostream> #include <limits> #define NOMINMAX #undef max template <typename T> class UntrackedAllocator { public: typedef T value_type; typedef value_type* pointer; typedef const value_type* const_pointer; typedef value_type& reference; typedef const value_type& const_reference; ..

Read more

Should these member functions(i.e: max_size(), construct() and destroy()) be implemented when defining a STL allocator by myself with std=c++11 option? Are there some potential problems that I should be aware of when invoking the STL with the allocator without these aforementioned member functions? As per https://en.cppreference.com/w/cpp/memory/allocator, these member functions are deprecated in C++17 and removed ..

Read more

Should these member functions(i.e: max_size(), construct() and destroy()) be implemented when defining a STL allocator by myself with std=c++11 option? Are there some potential problems that I should be aware of when invoking the STL with the allocator without these aforementioned member functions? As per https://en.cppreference.com/w/cpp/memory/allocator, these member functions are deprecated in C++17 and removed ..

Read more

Should these member functions (i.e: max_size(), construct() and destroy()) be implemented when defining an allocator by myself with std=c++11 option? Are there some potential problems that I should be aware of when invoking the STL containers with the allocator without these aforementioned member functions? As per https://en.cppreference.com/w/cpp/memory/allocator, these member functions are deprecated in C++17 and ..

Read more