Topic
2 replies Latest Post - ‏2013-07-01T16:10:27Z by Kevin_Foster
Kevin_Foster
Kevin_Foster
98 Posts
ACCEPTED ANSWER

Pinned topic question on a map's memory usage

‏2013-07-01T15:21:35Z |

I'm a bit surprised with the amount of memory that one of my maps is using.

I've experimented with various numbers of map entries - 1, 1000, 500000, 1M - and the map seems to be using approximately 200 bytes per entry. The size of each map entry is quite a bit smaller than 200 bytes:


type
  MyMapKeySchema = tuple<uint64 aa, rstring [ 10 ] bb> ;
  MyMapValueSchema = tuple<rstring [ 15 ] cc, timestamp dd> ;
...
  mutable map<MyMapKeySchema, MyMapValueSchema> myMap ;
 

So I'm wondering if this memory consumption is to be expected, and also whether there's any way to lower the memory consumption.

-Kevin

  • NSchulz
    NSchulz
    22 Posts
    ACCEPTED ANSWER

    Re: question on a map's memory usage

    ‏2013-07-01T15:54:24Z  in response to Kevin_Foster

    Hi Kevin,

    feeling a bit stupid writing the following lines, as if I'm on the right track here, it feels a bit ineffective, but fits well to observations I made previously in some of my test runs ...

    ... nevertheless ...

    Do your numbers make more sense if you assume that the system reserves 64Bits per each rstring character, like so:

    (10 + 15) * 64Bit = 25 * 64Bit = 1600 Bit = 200 * 8Bit = 200 Byte

    - Norbert

     

    • Kevin_Foster
      Kevin_Foster
      98 Posts
      ACCEPTED ANSWER

      Re: question on a map's memory usage

      ‏2013-07-01T16:10:27Z  in response to NSchulz

      I just changed one of the fields from rstring[15] to rstring[5] but it did not seem to change the memory usage.

      -Kevin