Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
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 Go to previous messageGo to previous message
dolik.rce is currently offline  dolik.rce
Messages: 1791
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

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
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: NEW: generic Toupel grouper
Next Topic: FIX: Value has Value, Value Type VALUE_V
Goto Forum:
  


Current Time: Sun Apr 27 05:19:25 CEST 2025

Total time taken to generate the page: 0.02718 seconds