Click here to Skip to main content
15,908,172 members
Home / Discussions / ATL / WTL / STL
   

ATL / WTL / STL

 
GeneralRe: How memory efficient is std::set? Pin
Dave Cross18-Sep-06 23:15
professionalDave Cross18-Sep-06 23:15 
GeneralRe: How memory efficient is std::set? Pin
Jörgen Sigvardsson18-Sep-06 23:27
Jörgen Sigvardsson18-Sep-06 23:27 
AnswerRe: How memory efficient is std::set? Pin
Jörgen Sigvardsson18-Sep-06 8:12
Jörgen Sigvardsson18-Sep-06 8:12 
AnswerRe: How memory efficient is std::set? Pin
Stuart Dootson18-Sep-06 21:16
professionalStuart Dootson18-Sep-06 21:16 
GeneralRe: How memory efficient is std::set? Pin
Jörgen Sigvardsson18-Sep-06 21:30
Jörgen Sigvardsson18-Sep-06 21:30 
GeneralRe: How memory efficient is std::set? Pin
Dave Cross18-Sep-06 22:20
professionalDave Cross18-Sep-06 22:20 
GeneralRe: How memory efficient is std::set? [modified] Pin
Stuart Dootson19-Sep-06 0:32
professionalStuart Dootson19-Sep-06 0:32 
GeneralRe: How memory efficient is std::set? Pin
Zac Howland19-Sep-06 3:33
Zac Howland19-Sep-06 3:33 
Stuart Dootson wrote:
Now, I'd guess most std::set implementations will have a similar level of overhead. So....I'm guessing you don't want to use std::set if you're tight on memory


That is correct, at a minimum. Since each node in the set must have 2 pointers (to the left and right children of the node) at the very least (and some implementations also carry pointers to the parent node as well).

If you are trying to keep your memory footprint down, vector is the way to go (assuming you have a good estimate on how many elements it will contain and can reserve that memory at some point). That said, deque will be more memory friendly if you have a lot of elements. The reasoning is fairly simple: if you estimate 10,000 elements for your vector, but end up addign 10,001, vector will try to reallocate to 15,000 elements and copy over the 10,001. With such a large memory footprint, for a few moments in CPU time, you will have more than double the required memory being allocated just to add a single element. In the same scenario, deque will just allocate another large chuck of data somewhere and add your single element in that chunk.

set isn't very memory friendly. It is designed to contain unique elements that are pre-sorted for you, making it more efficient for certain types of operations, but definitely not on memory usage.

If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week

Zac

Questionvariant and BSTR interactions Pin
Samy_Ibraheem_Mo17-Sep-06 10:18
Samy_Ibraheem_Mo17-Sep-06 10:18 
AnswerRe: variant and BSTR interactions Pin
Samy_Ibraheem_Mo17-Sep-06 11:43
Samy_Ibraheem_Mo17-Sep-06 11:43 
GeneralRe: variant and BSTR interactions Pin
Jörgen Sigvardsson17-Sep-06 12:12
Jörgen Sigvardsson17-Sep-06 12:12 
QuestionATL Control Pin
Demian Panello15-Sep-06 2:36
Demian Panello15-Sep-06 2:36 
Questionevent_source(com), event_receiver(com, true) __hooking problem Pin
sman_nz14-Sep-06 7:17
sman_nz14-Sep-06 7:17 
AnswerRe: event_source(com), event_receiver(com, true) __hooking problem Pin
Alex Boyce15-Sep-06 10:41
Alex Boyce15-Sep-06 10:41 
Questionshould we prefer deque over vector Pin
yccheok14-Sep-06 0:28
yccheok14-Sep-06 0:28 
AnswerRe: should we prefer deque over vector Pin
Zac Howland14-Sep-06 3:21
Zac Howland14-Sep-06 3:21 
GeneralRe: should we prefer deque over vector Pin
Jörgen Sigvardsson14-Sep-06 7:30
Jörgen Sigvardsson14-Sep-06 7:30 
Questionwtl window class / aligmnent? Pin
Marcin Parka13-Sep-06 19:58
Marcin Parka13-Sep-06 19:58 
QuestionPassing BSTR from javascript to ATL Pin
rana7413-Sep-06 3:01
rana7413-Sep-06 3:01 
QuestionSTL Algorithms Pin
Zac Howland12-Sep-06 11:11
Zac Howland12-Sep-06 11:11 
AnswerRe: STL Algorithms Pin
Christian Graus12-Sep-06 11:41
protectorChristian Graus12-Sep-06 11:41 
GeneralRe: STL Algorithms Pin
Stuart Dootson12-Sep-06 14:19
professionalStuart Dootson12-Sep-06 14:19 
GeneralRe: STL Algorithms Pin
Zac Howland12-Sep-06 16:59
Zac Howland12-Sep-06 16:59 
AnswerRe: STL Algorithms Pin
Michael Dunn12-Sep-06 20:21
sitebuilderMichael Dunn12-Sep-06 20:21 
GeneralRe: STL Algorithms Pin
Stephen Hewitt12-Sep-06 22:08
Stephen Hewitt12-Sep-06 22: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.