<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Initializing STL vector in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/initializing-stl-vector/m-p/4005891#M93935</link>
    <description>Hai,&lt;BR /&gt;We use -AA compiler option since RW Edition 8 requires Standard C++ libraries. We found similar issue in string initialization also.&lt;BR /&gt;When we run the following code we get the output as 128.&lt;BR /&gt;&lt;BR /&gt;string str("abc");&lt;BR /&gt;cout &amp;lt;&amp;lt; "size of string = " &amp;lt;&amp;lt; str.capacity() &amp;lt;&amp;lt; endl;&lt;BR /&gt;&lt;BR /&gt;Same code when run on sun, we get 3 as output.&lt;BR /&gt;&lt;BR /&gt;In our application we many such containers and strings. As a result of moving to standard C++ libraries, size of our application has increased many folds when compared to our previous version where we were using classic STL. Is there a way to minimize the memory consumption of these containers Standard C++ libraries? Please suggest.</description>
    <pubDate>Thu, 24 May 2007 10:18:39 GMT</pubDate>
    <dc:creator>Karthik Purushothaman</dc:creator>
    <dc:date>2007-05-24T10:18:39Z</dc:date>
    <item>
      <title>Initializing STL vector</title>
      <link>https://community.hpe.com/t5/operating-system-linux/initializing-stl-vector/m-p/4005889#M93933</link>
      <description>We are using RW Sourcepro ED8 on HP-UX 11.11 and Solaris 5.9. Our RW is built using Native STL provided by compiler. We see a difference in behaviour of RWTPtrOrderedVector initialization in Sun and HP. &lt;BR /&gt;Consider the following code snippet&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;RWTPtrOrderedVector&lt;LONG&gt; rwLongVec(4);&lt;BR /&gt;&lt;BR /&gt;In Sun, memory is allocated only for 4 items but in HP, memory seems to be allocated for 32 items even &lt;BR /&gt;though we specify 4 in the constructor. But when we specify value more than 32 in RWTPtrOrderedVector &lt;BR /&gt;consturctor, both Sun and HP seems to behave in same way.&lt;BR /&gt;&lt;BR /&gt;We create millions of such RWTPtrOrderedVector objects (each will have not more than 4 items)in our &lt;BR /&gt;application and hence we see a huge difference in memory footprint of our application in SUN and HP. &lt;BR /&gt;&lt;BR /&gt;We reported this with Roguewave. They concluded that the issue/difference is due to different implementation in HP-UX for the vector class. How do we fix this so we allocate memory only for the number of items we provide in constructor?&lt;/LONG&gt;</description>
      <pubDate>Wed, 23 May 2007 12:26:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/initializing-stl-vector/m-p/4005889#M93933</guid>
      <dc:creator>Thiagu_1</dc:creator>
      <dc:date>2007-05-23T12:26:02Z</dc:date>
    </item>
    <item>
      <title>Re: Initializing STL vector</title>
      <link>https://community.hpe.com/t5/operating-system-linux/initializing-stl-vector/m-p/4005890#M93934</link>
      <description>Are you using -AP or -AA?  There are two different ways to control things.&lt;BR /&gt;&lt;BR /&gt;RWTPtrOrderedVector&lt;LONG&gt; rwLongVec(4);&lt;BR /&gt;&amp;gt;In Sun, memory is allocated only for 4 items but in HP, memory seems to be allocated for 32 items even though we specify 4 in the constructor.&lt;BR /&gt;&lt;BR /&gt;The RW version we have assumes that you are going to grow the vector and doesn't want to keep coping the elements when you add more.&lt;BR /&gt;&lt;BR /&gt;&amp;gt;We create millions of such RWTPtrOrderedVector objects (each will have not more than 4 items)&lt;BR /&gt;&lt;BR /&gt;&amp;gt;We reported this with Roguewave. They concluded that the issue/difference is due to different implementation in HP-UX for the vector class.&lt;BR /&gt;&lt;BR /&gt;They could have given you their documentation on how to do it.  ;-)&lt;BR /&gt;&lt;BR /&gt;&amp;gt;How do we fix this so we allocate memory only for the number of items we provide in constructor?&lt;BR /&gt;&lt;BR /&gt;Using google I found it documented on:&lt;BR /&gt;&lt;A href="http://docs.hp.com/en/1559/libs.htm" target="_blank"&gt;http://docs.hp.com/en/1559/libs.htm&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;See "Allocation Policies for Containers".&lt;BR /&gt;&lt;BR /&gt;In your case of RWTPtrOrderedVector&lt;LONG&gt;, this creates a std::vector&lt;LONG&gt;.&lt;/LONG&gt;&lt;/LONG&gt;&lt;/LONG&gt;</description>
      <pubDate>Thu, 24 May 2007 03:11:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/initializing-stl-vector/m-p/4005890#M93934</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2007-05-24T03:11:54Z</dc:date>
    </item>
    <item>
      <title>Re: Initializing STL vector</title>
      <link>https://community.hpe.com/t5/operating-system-linux/initializing-stl-vector/m-p/4005891#M93935</link>
      <description>Hai,&lt;BR /&gt;We use -AA compiler option since RW Edition 8 requires Standard C++ libraries. We found similar issue in string initialization also.&lt;BR /&gt;When we run the following code we get the output as 128.&lt;BR /&gt;&lt;BR /&gt;string str("abc");&lt;BR /&gt;cout &amp;lt;&amp;lt; "size of string = " &amp;lt;&amp;lt; str.capacity() &amp;lt;&amp;lt; endl;&lt;BR /&gt;&lt;BR /&gt;Same code when run on sun, we get 3 as output.&lt;BR /&gt;&lt;BR /&gt;In our application we many such containers and strings. As a result of moving to standard C++ libraries, size of our application has increased many folds when compared to our previous version where we were using classic STL. Is there a way to minimize the memory consumption of these containers Standard C++ libraries? Please suggest.</description>
      <pubDate>Thu, 24 May 2007 10:18:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/initializing-stl-vector/m-p/4005891#M93935</guid>
      <dc:creator>Karthik Purushothaman</dc:creator>
      <dc:date>2007-05-24T10:18:39Z</dc:date>
    </item>
    <item>
      <title>Re: Initializing STL vector</title>
      <link>https://community.hpe.com/t5/operating-system-linux/initializing-stl-vector/m-p/4005892#M93936</link>
      <description>&amp;gt;We found similar issue in string initialization also.&lt;BR /&gt;&lt;BR /&gt;Yes, all containers types assume they are going to grow.  You can either see my link where __rw_new_capacity is used to change the allocation, or there are a few defines that could be added for -AA:&lt;BR /&gt;#  define _RWSTD_MINIMUM_NEW_CAPACITY size_t(32)&lt;BR /&gt;#  define _RWSTD_NEW_CAPACITY_RATIO float(1.618)&lt;BR /&gt;&lt;BR /&gt;#  define _RWSTD_MINIMUM_STRING_CAPACITY size_t(128)&lt;BR /&gt;#  define _RWSTD_STRING_CAPACITY_RATIO float(1.618)&lt;BR /&gt;&lt;BR /&gt;The first two work for ALL containers.  The last two are only for strings.&lt;BR /&gt;&lt;BR /&gt;Note the 32 and the 128 that you are seeing.&lt;BR /&gt;</description>
      <pubDate>Thu, 24 May 2007 18:27:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/initializing-stl-vector/m-p/4005892#M93936</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2007-05-24T18:27:54Z</dc:date>
    </item>
    <item>
      <title>Re: Initializing STL vector</title>
      <link>https://community.hpe.com/t5/operating-system-linux/initializing-stl-vector/m-p/4005893#M93937</link>
      <description>&lt;P&gt;If you have gotten the answers you wanted, you should assign points and close the thread. Please read the following:&lt;BR /&gt;&lt;A href="http://forums1.itrc.hp.com/service/forums/helptips.do?#33" target="_blank"&gt;http://forums.itrc.hp.com/service/forums/helptips.do?#33&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 25 Sep 2011 22:12:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/initializing-stl-vector/m-p/4005893#M93937</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2011-09-25T22:12:10Z</dc:date>
    </item>
  </channel>
</rss>

