[Dev-C++] Optimized memory allocation
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Shane B. <ast...@te...> - 2003-06-20 00:38:55
|
Hello,
I have recently been attempting to find ways to speed up the process =
of loading 48k records from a MySQL SELECT statement, which has a 32 =
char primary key. One of the more intensive processes involved is =
calling "new" to create a new object 48k times. In standard C, I would =
malloc(RowCount * sizeof(class_type)), and using pointer math, simply =
iterate whenever I needed a new structure. With C++, a call to new is =
required for construction purposes. Is there an optimized method =
wherein I can allocate a dynamic number to be preallocated more =
efficiently all at once in one call?
I have considered using "new class_type[RowCount]()" to allocate an =
array (haven't tried to see if that would actually work), but I was =
wondering if there was a more efficient means to preallocate objects.
Thanks,
-Shane |