I am at a point in a project where I am unsure which direction I should go

I want to create a class that will store string data (which will be static in length) along with some other information - I would like some advice on how best to proceed.

Currently I allocate a chunk of memory for all of the data and use my own structs to access that information. I keep track of how many records I have and when needed I reallocate more memory.

If I create object for each record and store the information internally within the object would this result in the memory becoming fragmented (there will be several thousand records)

Another method which I have thought of using would be similar to the current approach but where I allocate a chunk of memory and point the classes private data to the memory, but this defeats the purpose of the class and keeping it's internal data private.

Any thoughts or comments would be appreciated.

Taff
Posted on 2005-03-07 03:43:56 by taff
This is actually already given to you with HeapCreate and all HeapXXX API :) . Its granularity is around 16 or 32 bytes iirc (aligns newly requested data) - which is good enough imho.
But well, if you want to have fun reinventing the wheel (like most of us do very often), you should use VirtualAlloc to allocate chunks whose size is a multiple of 64kB (your chunks should be 64kB, 128kB,...1MB..), and have some kind of linked-list for descriptions of the small chunks.
But since you will use this for memory objects with the same size, just define some bitfield for which cells are free and which - not. This makes the class object a lot easier to make ;)

Which asm OOP package are you interested in developing with?
Posted on 2005-03-07 11:35:20 by Ultrano