Click here to Skip to main content
15,915,834 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Parsing a integer value as a Parameter Pin
Nemanja Trifunovic24-Oct-06 9:39
Nemanja Trifunovic24-Oct-06 9:39 
QuestionA simple question about memory reallocation Pin
pani6824-Oct-06 8:25
pani6824-Oct-06 8:25 
AnswerRe: A simple question about memory reallocation Pin
David Crow24-Oct-06 8:29
David Crow24-Oct-06 8:29 
AnswerRe: A simple question about memory reallocation Pin
Mark Salsbery24-Oct-06 8:44
Mark Salsbery24-Oct-06 8:44 
AnswerRe: A simple question about memory reallocation Pin
Zac Howland24-Oct-06 10:57
Zac Howland24-Oct-06 10:57 
AnswerRe: A simple question about memory reallocation Pin
cmk24-Oct-06 11:25
cmk24-Oct-06 11:25 
GeneralRe: A simple question about memory reallocation Pin
Zac Howland24-Oct-06 11:36
Zac Howland24-Oct-06 11:36 
GeneralRe: A simple question about memory reallocation Pin
cmk25-Oct-06 6:11
cmk25-Oct-06 6:11 
Zac Howland wrote:
vector uses an algorithm to pre-buffer memory for you


My comment still stands, when vector needs to increase the size of memory it has to alloc a new larger chunk, copy the existing members to the new block, then free the old block, same as realloc.

At _best_ this is a wash in comparison to realloc. If new explicitly touches each member in the array for POD's and sets to zero, then this would likely be less efficient than calloc. I would hope the VS compiler optimizes this step out, but i believe it would be compiler specific.

I am aware of the pre-buffer method, i use it in my container classes as well, it is a method that i would hope the OP would uses with realloc as well, but it is at a higher _level_ than the realloc discussion.

... the virtual memory comment was slightly tounge-in-cheek ... however, seeing as we are arguing ... i would say that using the virtual mem api's to manage your own alloc/realloc is good or bad depending on how it is used, it is just another tool. Using virtual mem to manage your own pool of objects of a specific type can be a huge win (in fact you could do this to create a custom alloc for vector), in most other cases i would agree that at best you would achieve performance comparable to what the Heap*() api functions provide.


...cmk

Save the whales - collect the whole set

GeneralRe: A simple question about memory reallocation Pin
Zac Howland25-Oct-06 6:28
Zac Howland25-Oct-06 6:28 
GeneralRe: A simple question about memory reallocation Pin
cmk25-Oct-06 8:10
cmk25-Oct-06 8:10 
GeneralRe: A simple question about memory reallocation Pin
Zac Howland25-Oct-06 8:35
Zac Howland25-Oct-06 8:35 
QuestionText does not show on toolbar Pin
peterchen24-Oct-06 7:35
peterchen24-Oct-06 7:35 
AnswerRe: Text does not show on toolbar Pin
Mark Salsbery24-Oct-06 7:59
Mark Salsbery24-Oct-06 7:59 
GeneralRe: Text does not show on toolbar Pin
peterchen24-Oct-06 13:02
peterchen24-Oct-06 13:02 
GeneralRe: Text does not show on toolbar Pin
Mark Salsbery24-Oct-06 13:14
Mark Salsbery24-Oct-06 13:14 
Questionnavigation for vectorRichEditBox Pin
prithaa24-Oct-06 7:11
prithaa24-Oct-06 7:11 
AnswerRe: navigation for vectorRichEditBox Pin
prithaa24-Oct-06 7:18
prithaa24-Oct-06 7:18 
GeneralRe: navigation for vectorRichEditBox Pin
prithaa24-Oct-06 7:25
prithaa24-Oct-06 7:25 
QuestionRe: navigation for vectorRichEditBox Pin
Maximilien24-Oct-06 7:58
Maximilien24-Oct-06 7:58 
AnswerRe: navigation for vectorRichEditBox Pin
prithaa24-Oct-06 8:11
prithaa24-Oct-06 8:11 
GeneralRe: navigation for vectorRichEditBox Pin
Mark Salsbery24-Oct-06 8:28
Mark Salsbery24-Oct-06 8:28 
AnswerRe: navigation for vectorRichEditBox Pin
David Crow24-Oct-06 8:32
David Crow24-Oct-06 8:32 
GeneralRe: navigation for vectorRichEditBox Pin
prithaa24-Oct-06 9:50
prithaa24-Oct-06 9:50 
GeneralRe: navigation for vectorRichEditBox Pin
prithaa24-Oct-06 10:07
prithaa24-Oct-06 10:07 
GeneralRe: navigation for vectorRichEditBox Pin
David Crow24-Oct-06 10:08
David Crow24-Oct-06 10:08 

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.