moya-lang / Allocator

Ultra fast C++11 allocator for STL containers.
BSD 2-Clause "Simplified" License
273 stars 25 forks source link

Pushback test fails with bad_alloc if modified to use std::vector #17

Closed mcordery closed 2 years ago

mcordery commented 2 years ago

Modified Measure.cpp to include a pushback test for std::vector

include

PushBackTest<std::vector<DataType>> pushBackVectorTestStl;
PushBackTest<std::vector<DataType, MemoryPoolAllocator>> pushBackVectorTestFast;
printTestStatus("Vector PushBack", pushBackVectorTestStl, pushBackVectorTestFast);

At run time this fails with

terminate called after throwing an instance of 'std::bad_alloc' what(): std::bad_alloc Aborted (core dumped)

mcordery commented 2 years ago

Also fails with clang++

moya-mmoczala commented 2 years ago

Vector doesn't need to be speed up as it already allocates a fixed amount of memory. The Allocator does not support such containers and it was intended by its design.