Re: Memory occupied by Map



On Thu, 12 Jun 2008 17:12:29 -0700 (PDT), "alien.0101@xxxxxxxxx"
<alien.0101@xxxxxxxxx> wrote:

Hi

I want to know the memory occupied by Map, Is there a way to do that.

I have written a sample application and adding value to map doesnot
change size
map<int,int> mapInt2Int;
mapInt2Int[1]=2;
mapInt2Int[2]=2;
mapInt2Int[3]=2;
mapInt2Int[4]=2;
mapInt2Int[5]=2;
mapInt2Int[6]=2;
size_t sz= sizeof(mapInt2Int);

The result of the sizeof operator is a constant fixed at compile-time.

How can I find how much bytes does the map uses.

You can't, at least not without becoming steeped in the details of the
implementation.

My main requirement is to store the map as a byte blob in database and
rettrieve back.

any thoughts???

Serialize the map as (key, value) pairs.

--
Doug Harrison
Visual C++ MVP
.



Relevant Pages

  • Re: Efficient hashmap serialization?
    ... > objects in that map, grouped in a threaded message fashion. ... > I serialize this map to send it over RMI, ... or are you using a proper message abstraction type? ...
    (comp.lang.java.programmer)
  • std::map and serialization
    ... MFC n00b here, I'm trying to serialize a std::map obj into disk. ... code above is inside a for loop that loops through the elements in the map). ...
    (microsoft.public.vc.mfc)
  • Efficient hashmap serialization?
    ... I have a a hash map full of objects that contain references to other ... grouped in a threaded message fashion. ... linked list style previous messages and next message. ... I serialize this map to send it over RMI, ...
    (comp.lang.java.programmer)
  • YAML Problem
    ... I would like to serialize a hash, ... but deserialize say: Invalid element in map ...
    (comp.lang.perl.misc)
  • Help! Mapper - do not show empty nodes
    ... Is there a way to not serialize or show empty destination nodes in the ... BizTalk mapper? ... I output a large file, map it, then send it somewhere. ...
    (microsoft.public.biztalk.general)

Loading