Click here to Skip to main content
12,894,656 members (64,465 online)
Click here to Skip to main content


43 bookmarked
Posted 16 Jun 2009

Session of low-level optimization of memory usage in C++ programs with total exposure

, , 22 Jun 2009 CPOL
In this article, we will try to make our algorithms work faster using the methods of low-level optimization of memory allocation in C++.

#include "new"
#include "base_allocators.h"

namespace utils

template<class ObjectType, class ParamType>
struct crt_allocator

    ObjectType * NewChars(size_t count)
       ObjectType * p = (ObjectType *)malloc(count);
       if (!p)
          throw std::bad_alloc();
       return p;
    ObjectType * New(size_t count)
       ObjectType * p = (ObjectType *)malloc(count * sizeof(ObjectType));
       if (!p)
          throw std::bad_alloc();
       return p;

    void Delete(void * ptr, size_t)

} // utils

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Authors

No Biography provided

Apriorit Inc
Apriorit Inc.
Hungary Hungary
ApriorIT is a Software Research and Development company that works in advanced knowledge-intensive scopes.

Company offers integrated research&development services for the software projects in such directions as Corporate Security, Remote Control, Mobile Development, Embedded Systems, Virtualization, Drivers and others.

Official site
Group type: Organisation

32 members

You may also be interested in...

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.170424.1 | Last Updated 23 Jun 2009
Article Copyright 2009 by Victor A. Milokum, Apriorit Inc
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid