Vector backed by memory pages The purpose of this class is to wrap a std::vector in a class so that never a new object is added. We don't allocate a new object on the stack but we trying to fit it on the current memory page, or create a new page for it.

#include &lt;vector&gt;

template&lt;class T&gt;
class  PagedVector {

public :
    PagedVector(int initialCapacity, float load_factor = 1.5f):
    pageSize(static_cast&lt;size_t&gt;(load_factor*initialCapacity*sizeof(T))),
    current_byte_offset(0),
    current_page(0)
    {
        data.reserve(initialCapacity);

        //initialise one page:
        char* ptr = static_cast&lt;char*&gt;(malloc(pageSize));
        pages.push_back(std::make_pair(ptr, pageSize));
    }

    template&lt;class U&gt;
    U* create() {
        char* memoryPtr = getNextAdress(sizeof(U), std::alignment_of&lt;U&gt;::value);
        U* objectPtr = new (memoryPtr) U();
        data.push_back(objectPtr);
        return objectPtr;
    }

    ~PagedVector() {
        //delete objects
        for(T* obj : data) {
            obj-&gt;~T();
        }

        //free memory
        for(auto&amp; pair : pages) {
            free(pair.first);
        }
    }

    void reset() {
        //delete objects
        for(T* obj : data) {
            obj-&gt;~T();
        }
        data.clear();

        //keep memory but reset page count
        current_page = 0;
        current_byte_offset = 0;
    }

    const std::vector&lt;T*&gt;&amp; getData() const {
        return data;
    }

private :
    std::vector&lt;T*&gt; data;
    std::vector&lt; std::pair&lt;char* , size_t &gt; &gt; pages;

    size_t pageSize;
    size_t current_byte_offset;
    int current_page;

    char* getNextAdress(size_t size, size_t align) {
        //get next available adress for type with given size and aligment

        char* current_page_adress = pages[current_page].first + current_byte_offset;
        char* end_page_adress = pages[current_page].first + pages.back().second;

        size_t remainder_align = reinterpret_cast&lt;uintptr_t&gt;(current_page_adress) % align;
        size_t extra_alignment_padding = remainder_align==0 ? 0 : (align - remainder_align);

        char* next_aligned_adress = current_page_adress + extra_alignment_padding;
        char* end_aligned_adress = next_aligned_adress + size;

        if(end_aligned_adress &lt; end_page_adress) {
            current_byte_offset += size + extra_alignment_padding;
            return next_aligned_adress;
        }

        //no more space on the current page, have to reallocate a new one:

        //in the rare case where the object size &gt; page size
        size_t nextPageSize = std::max(pageSize, size);

        char* ptr = static_cast&lt;char*&gt;(malloc(nextPageSize));
        pages.push_back(std::make_pair(ptr, nextPageSize));
        current_byte_offset = size;
        ++current_page;
        return ptr;
    }

    //non-copiable:
    PagedVector(PagedVector&amp;);
    PagedVector&amp; operator=(PagedVector&amp;);
};


Usage:

PagedVector&lt;Base&gt; pv(5);
    pv.create&lt;Base&gt;();
    Derived* p = pv.create&lt;Derived&gt;();


I'm wondering if this is correct (not relying on UB). I've never dealt that much with placement new and manual memory management.
I usually focus on the design and this review won't be different. You seem to have created some custom universal allocator, that will place all the (different) objects in continuous space (a page) or create new page if needed. The whole space can be released all at once, but no individual objects. So...

void reset() {
    //delete objects
    for(T* obj : data) {
        obj-&gt;~T(); // &lt;&lt;&lt; will not call the appropriate destructor if not virtual


This can be very problematic, unless T has virtual destructor, you should place some static_assert:

template&lt;class T&gt;
class  PagedVector {
    static_assert(std::has_virtual_destructor&lt;T&gt;::value,
        "Objects without virtual destructor cannot be used");


Similar problem is in create allowing any class, should allow derived only:

template&lt;class U&gt;
U* create() {
    static_assert(std::is_same&lt;U,T&gt;::value || std::is_base_of&lt;T,U&gt;::value,
        "Objects not derived from T are not allowed");




Minor note about = delete:

//non-copiable:
PagedVector(PagedVector&amp;);
PagedVector&amp; operator=(PagedVector&amp;);


The above should be written with const and = delete to avoid using it inside the class:

//non-copiable:
PagedVector(const PagedVector&amp;) = delete;
PagedVector&amp; operator=(const PagedVector&amp;) = delete;