Home » U++ Library support » U++ Core » Value question (memory consumption)
Re: Value question (memory consumption) [message #29914 is a reply to message #29906] |
Mon, 29 November 2010 21:23   |
|
Hi Factor,
This is actually not related to Value at all. If you try the same with Vector<int>, you will notice the same behavior.
I think it is caused by the way Vector allocates memory when it grows. If you do v.SetCount(ITEM_COUNT,0), instead of series of Add() calls and then call Clear() and Shrink, you will get back at the memory usage you started with.
I am not sure if this is a bug. I have a strange feeling that this might be actually result of how OS manages the memory. If you ask it for a big chunk at once and then return it later, it might work different than when you are asking for chunks of size increasing as powers of two (which is what vector does).
Maybe someone knowing the memory handling better than me might shed some more light into this. But from what I've seen, I would recommend to use SetCount() every time you know how many items will be necessary.
Best regards,
Honza
|
|
|
 |
|
Value question (memory consumption)
By: Factor on Mon, 29 November 2010 11:31
|
 |
|
Re: Value question (memory consumption)
|
 |
|
Re: Value question (memory consumption)
|
 |
|
Re: Value question (memory consumption)
By: unknown user on Mon, 29 November 2010 22:57
|
 |
|
Re: Value question (memory consumption)
By: mirek on Tue, 30 November 2010 13:21
|
 |
|
Re: Value question (memory consumption)
|
 |
|
Re: Value question (memory consumption)
By: mirek on Tue, 30 November 2010 14:26
|
 |
|
Re: Value question (memory consumption)
By: mirek on Tue, 30 November 2010 13:36
|
 |
|
Re: Value question (memory consumption)
By: mirek on Tue, 30 November 2010 14:46
|
 |
|
Re: Value question (memory consumption)
By: unknown user on Tue, 30 November 2010 16:48
|
 |
|
Re: Value question (memory consumption)
|
 |
|
Re: Value question (memory consumption)
By: mirek on Sat, 11 December 2010 10:38
|
 |
|
Re: Value question (memory consumption)
By: mr_ped on Tue, 30 November 2010 09:13
|
 |
|
Re: Value question (memory consumption)
By: mirek on Tue, 30 November 2010 13:25
|
Goto Forum:
Current Time: Sun Apr 27 14:45:04 CEST 2025
Total time taken to generate the page: 0.03327 seconds
|