Be careful about the associated containers in Cstd of SunStudio

If your program has a lot of std::set<T> or std::map<T> object instances, while mostly have small sizes (e.g., 1..5), you'd better change them to Vector or other unassociated container types if you built your code with Cstd in SunStudio.

The genpyt utility in sunpinyin/slm module, takes over 800M virtual memory, and about 4~500M is allocated for the unused __rb_tree_node buffer. If your machine has less memory than 1GB, the paging in/out (to/from swap) will make the program (and your system) running very slowly.

E.g., for the following example,

std::set<TNode*> nodeset;
nodeset.insert (new TNode());

During the std::set<TNode*>::insert(TNode*), the underlying __rb_tree structure would allocate 32 __rb_tree_node (whose size is 20 bytes), in total 640 bytes. While you just want it to hold a 4/8 bytes pointer. If your program has a lot of such small Set objects, the "wasted" memory is quite large.

I tested g++, and SunStudio with stlport4, they do not has such problem (or feature ;)).

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

To submit your comment, click the image below where it asks you to...
Clickcha - The One-Click Captcha