Oversized memory allocation by ACE library's thread (ACE_Task_Base) class

Posted on 2007-10-16
Last Modified: 2012-06-27
Hello, I'm using the ACE library for a multi threaded network application written in C++ for linux.

I'm using ACE for network layer, threads and semaphores.

Everything goes well, but we recently realized that the threads are allocating big blocks of memory.
When running pmap on our program, we see lines like

b75da000  10240K rwx--    [ anon ]

There is one for each thread, and this seems really oversized.
For more details, our threads are handled in a class derived from ACE_Task_Base. The 10 megs memory blocks are allocated only if we start the threads.

Any advice about why this memory is allocated, is it necessary, and if not, how to reduce or remove these allocations ? Can it be related to not using the ACE_Thread_Manager ?

Question by:KCTeam
    LVL 7

    Expert Comment

    try clearing the free lists and the unbounded memory it stores.
    Basically what i mean is these threads may be allocating extra unused buffer for their smooth functioning.
    Try to free this extra allocation after the threads are spawned.

    This may be taken care by  the thread manager, which you are not using.

    The following link may:
    LVL 7

    Expert Comment

    continuing the previous comment.......

    construction of thread manager requires all minimum foot print, increments and maximum values.

    If you dont wanna use, you need to do all this functionality yourself!!
    Plz see the link described in previous comment.

    Author Comment

    Thanks for the link quick replies and info.

    I finally figured out that this corresponds to the default thread stack size.
    It seems that ACE supports arguments to modify this when calling ACE_Task_Base::activate, but I couldn't get it to work.
    However, the shell command "ulimit -s N" did the job.  

    Accepted Solution

    The ACE_Task_Base not taking the stack size parameter is a bug.
    See (need to expand last post)

    After recompiling ACE as described on this page it worked.
    Change ACE_wrappers/ace/

    Old LDFLAGS: 
    libACE_la_LDFLAGS = \ 
     -release @ACE_VERSION_NAME@ 
    New LDFLAGS: 
    libACE_la_LDFLAGS = \ 
     -release @ACE_VERSION_NAME@ -lpthread

    Open in new window

    LVL 1

    Expert Comment

    Closed, 500 points refunded.
    Community Support Moderator

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
    Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
    The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
    The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now