- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Initializing STL vector
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-23-2007 05:26 AM
тАО05-23-2007 05:26 AM
Initializing STL vector
Consider the following code snippet
RWTPtrOrderedVector
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. But when we specify value more than 32 in RWTPtrOrderedVector
consturctor, both Sun and HP seems to behave in same way.
We create millions of such RWTPtrOrderedVector objects (each will have not more than 4 items)in our
application and hence we see a huge difference in memory footprint of our application in SUN and HP.
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-23-2007 08:11 PM
тАО05-23-2007 08:11 PM
Re: Initializing STL vector
RWTPtrOrderedVector
>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.
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.
>We create millions of such RWTPtrOrderedVector objects (each will have not more than 4 items)
>We reported this with Roguewave. They concluded that the issue/difference is due to different implementation in HP-UX for the vector class.
They could have given you their documentation on how to do it. ;-)
>How do we fix this so we allocate memory only for the number of items we provide in constructor?
Using google I found it documented on:
http://docs.hp.com/en/1559/libs.htm
See "Allocation Policies for Containers".
In your case of RWTPtrOrderedVector
- Tags:
- containers
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-24-2007 03:18 AM
тАО05-24-2007 03:18 AM
Re: Initializing STL vector
We use -AA compiler option since RW Edition 8 requires Standard C++ libraries. We found similar issue in string initialization also.
When we run the following code we get the output as 128.
string str("abc");
cout << "size of string = " << str.capacity() << endl;
Same code when run on sun, we get 3 as output.
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-24-2007 11:27 AM
тАО05-24-2007 11:27 AM
Re: Initializing STL vector
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:
# define _RWSTD_MINIMUM_NEW_CAPACITY size_t(32)
# define _RWSTD_NEW_CAPACITY_RATIO float(1.618)
# define _RWSTD_MINIMUM_STRING_CAPACITY size_t(128)
# define _RWSTD_STRING_CAPACITY_RATIO float(1.618)
The first two work for ALL containers. The last two are only for strings.
Note the 32 and the 128 that you are seeing.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-14-2007 05:07 AM - edited тАО09-25-2011 03:12 PM
тАО07-14-2007 05:07 AM - edited тАО09-25-2011 03:12 PM
Re: Initializing STL vector
If you have gotten the answers you wanted, you should assign points and close the thread. Please read the following:
http://forums.itrc.hp.com/service/forums/helptips.do?#33