N
nathan_kent_bullock
In one section of my code, the allocating of memory is chewing up a
significant amount of time. I have solved most of the problem by
creating a custom memory allocator which uses memory pools.
Anyway, my problem is I don't now how to use this custom allocator for
non-builtin types. So for things like ints, doubles, etc this works
great but if I have a class called ClassA can I still do this?
Example:
// For basic types
varx = (int*)myallocator(10*sizeof(int));
// For ClassA
varx = (ClassA*)myallocator(10*sizeof(ClassA));
// but varx's constructor never gets called????
How do I use my custom allocator and initialize the object?
I can't globally overload new because I only want the special allocator
used in the one small area of my code. I can't overload new for
'ClassA' because of the same reason.
Nathan Bullock
significant amount of time. I have solved most of the problem by
creating a custom memory allocator which uses memory pools.
Anyway, my problem is I don't now how to use this custom allocator for
non-builtin types. So for things like ints, doubles, etc this works
great but if I have a class called ClassA can I still do this?
Example:
// For basic types
varx = (int*)myallocator(10*sizeof(int));
// For ClassA
varx = (ClassA*)myallocator(10*sizeof(ClassA));
// but varx's constructor never gets called????
How do I use my custom allocator and initialize the object?
I can't globally overload new because I only want the special allocator
used in the one small area of my code. I can't overload new for
'ClassA' because of the same reason.
Nathan Bullock