Click here to Skip to main content
15,914,419 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: CRYSTL32.OCX problem ! Pin
Hadi Rezaee9-Apr-02 10:02
Hadi Rezaee9-Apr-02 10:02 
GeneralWord Automation - Extra Info on Tables.. Pin
Braulio Dez8-Apr-02 22:41
Braulio Dez8-Apr-02 22:41 
GeneralSTL and heap management Pin
Haakon S.8-Apr-02 22:26
Haakon S.8-Apr-02 22:26 
GeneralRe: STL and heap management Pin
Christian Graus8-Apr-02 23:21
protectorChristian Graus8-Apr-02 23:21 
GeneralRe: STL and heap management Pin
Haakon S.9-Apr-02 0:20
Haakon S.9-Apr-02 0:20 
GeneralRe: STL and heap management Pin
Joao Vaz9-Apr-02 1:07
Joao Vaz9-Apr-02 1:07 
GeneralRe: STL and heap management Pin
Haakon S.9-Apr-02 1:50
Haakon S.9-Apr-02 1:50 
GeneralRe: STL and heap management Pin
Joao Vaz9-Apr-02 3:48
Joao Vaz9-Apr-02 3:48 
Haakon, CString is a MFC class , not a STL class, in STL we have the string template class.

The CString class internally will by default allocate the memory by a factor of 2, and internally maintains lists(not sure how many) of memory blocks , it controls the used memory blocks and unused memory blocks,
it guards the size and the nº of slots available for allocating in the used slots due to requests of different sizes, then when we ask to allocate something, it will search for the best size match on the slots, if it finds it uses the slot, if not it will request a unused block from another list and will allocate accordingly. This algorithm is used to prevent to minime memory fragmentation and improve allocattion time. A proper and much more correct and accurate explanation of this is on MFC Internals.

The stl string implememention is faster than the mfc counterpart, and it uses similar(or more complex) algorithms.

For articles talking about allocators check this articles, both from by Matt Austern, the chair of the C++ standardization committee’s library working group.

The Standard Librarian: What Are Allocators Good For?


The Standard Librarian: A Debugging Allocator


After reading this, perhaps you will feel the wish for not doing custom allocators ...

A note, implementing a block allocator for vector it's more tricky, because the standars mandates that the elements can be accessed on contiguous memory blocks .

ex:

vector<100> x;
while (...) { doSomething(&v[i++]); }

For other example of custom block allocator see here at CodeProject
A Custom Block Allocator for Speeding Up VC++ STL
By Joaquín M López Muñoz


As a sidenote this allocator don't work with vector neither deque(this containers allocates chunks like I tried to explaining).

Cheers,

Joao Vaz
GeneralRe: STL and heap management Pin
Tim Smith9-Apr-02 4:10
Tim Smith9-Apr-02 4:10 
GeneralRe: STL and heap management Pin
Joao Vaz9-Apr-02 4:49
Joao Vaz9-Apr-02 4:49 
GeneralRe: STL and heap management Pin
Haakon S.9-Apr-02 8:17
Haakon S.9-Apr-02 8:17 
GeneralRe: STL and heap management Pin
Joao Vaz9-Apr-02 9:56
Joao Vaz9-Apr-02 9:56 
GeneralRe: STL and heap management Pin
Tim Smith9-Apr-02 8:44
Tim Smith9-Apr-02 8:44 
GeneralRe: STL and heap management Pin
Joao Vaz9-Apr-02 10:03
Joao Vaz9-Apr-02 10:03 
GeneralClosing message! Pin
Rickard Andersson208-Apr-02 22:27
Rickard Andersson208-Apr-02 22:27 
GeneralRe: Closing message! Pin
lucy9-Apr-02 3:43
lucy9-Apr-02 3:43 
GeneralRe: Closing message! Pin
Rickard Andersson209-Apr-02 4:39
Rickard Andersson209-Apr-02 4:39 
General"Show window contents while dragging" Pin
Hans Ruck8-Apr-02 21:29
Hans Ruck8-Apr-02 21:29 
GeneralRe: "Show window contents while dragging" Pin
Shog99-Apr-02 5:27
sitebuilderShog99-Apr-02 5:27 
QuestionWhat is the difference between the dialog types available in resource editor? Pin
vcLearner8-Apr-02 21:30
vcLearner8-Apr-02 21:30 
AnswerRe: What is the difference between the dialog types available in resource editor? Pin
John Aspras8-Apr-02 21:36
John Aspras8-Apr-02 21:36 
GeneralProblem with LIKE from MFC Pin
8-Apr-02 19:31
suss8-Apr-02 19:31 
GeneralRe: Problem with LIKE from MFC Pin
Derek Waters8-Apr-02 19:35
Derek Waters8-Apr-02 19:35 
GeneralRe: Problem with LIKE from MFC Pin
Lakitu8-Apr-02 23:27
Lakitu8-Apr-02 23:27 
GeneralEnable/Disable Toolbar *Buttons* :: MFC Pin
valikac8-Apr-02 19:18
valikac8-Apr-02 19:18 

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.