Click here to Skip to main content
16,008,490 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: (Re)-allocation memory Pin
David Crow23-Jul-04 9:17
David Crow23-Jul-04 9:17 
GeneralRe: (Re)-allocation memory Pin
0v3rloader23-Jul-04 9:46
0v3rloader23-Jul-04 9:46 
GeneralRe: (Re)-allocation memory Pin
Ravi Bhavnani23-Jul-04 9:52
professionalRavi Bhavnani23-Jul-04 9:52 
GeneralRe: (Re)-allocation memory Pin
David Crow23-Jul-04 9:54
David Crow23-Jul-04 9:54 
GeneralRe: (Re)-allocation memory Pin
0v3rloader23-Jul-04 9:58
0v3rloader23-Jul-04 9:58 
GeneralRe: (Re)-allocation memory Pin
cmk23-Jul-04 9:56
cmk23-Jul-04 9:56 
GeneralRe: (Re)-allocation memory Pin
0v3rloader23-Jul-04 10:01
0v3rloader23-Jul-04 10:01 
GeneralRe: (Re)-allocation memory Pin
peterchen23-Jul-04 13:01
peterchen23-Jul-04 13:01 
forget aout reallocating memory, for most.

a) new/delete call Ctor and DTor of the element(s), which alloc does not
b) realloc isn't as useful or performant as one would wish, unless you have a single-threaded application and all the reallocations happen in one "block" (in which case it's typically possible, if painful, to calcuilate the total length first and allocate once).

The worst performance hit is not overallocation, but fragmentation, and typical "container" or "string builder" classes are designed to minimize that. The overhead of allocating a larger buffer and copying data is often negligible.

I would recommend using a container with contiguous memory (such as std::vector<byte> for this.



we are here to help each other get through this thing, whatever it is Vonnegut jr.

sighist || Agile Programming | doxygen

GeneralRe: (Re)-allocation memory Pin
cmk23-Jul-04 13:51
cmk23-Jul-04 13:51 
GeneralFile Associations Pin
---Mark---23-Jul-04 8:25
---Mark---23-Jul-04 8:25 
GeneralRe: File Associations Pin
palbano23-Jul-04 8:28
palbano23-Jul-04 8:28 
GeneralRe: File Associations Pin
PJ Arends23-Jul-04 15:08
professionalPJ Arends23-Jul-04 15:08 
GeneralDeclaration question... Pin
drjake23-Jul-04 7:20
drjake23-Jul-04 7:20 
GeneralRe: Declaration question... Pin
palbano23-Jul-04 8:07
palbano23-Jul-04 8:07 
GeneralRe: Declaration question... Pin
drjake23-Jul-04 8:16
drjake23-Jul-04 8:16 
GeneralRe: Declaration question... Pin
palbano23-Jul-04 8:27
palbano23-Jul-04 8:27 
GeneralRe: Declaration question... Pin
drjake23-Jul-04 8:56
drjake23-Jul-04 8:56 
GeneralRe: Declaration question... Pin
Henry miller26-Jul-04 8:21
Henry miller26-Jul-04 8:21 
GeneralRe: Declaration question... Pin
Ravi Bhavnani23-Jul-04 8:54
professionalRavi Bhavnani23-Jul-04 8:54 
QuestionError Registering DLL but not .EXE ?? Pin
Pradhip23-Jul-04 6:55
Pradhip23-Jul-04 6:55 
AnswerRe: Error Registering DLL but not .EXE ?? Pin
Chris Losinger23-Jul-04 9:25
professionalChris Losinger23-Jul-04 9:25 
GeneralUpdateAllViews() and Multi-Thread Pin
Danny Gilbert23-Jul-04 6:07
Danny Gilbert23-Jul-04 6:07 
GeneralRe: UpdateAllViews() and Multi-Thread Pin
vcplusplus23-Jul-04 7:21
vcplusplus23-Jul-04 7:21 
GeneralCFile question Pin
Shay Harel23-Jul-04 5:53
Shay Harel23-Jul-04 5:53 
GeneralRe: CFile question Pin
valikac23-Jul-04 6:10
valikac23-Jul-04 6:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.