?
Solved

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

Posted on 2007-10-16
6
Medium Priority
?
919 Views
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 ?

Thanks
0
Comment
Question by:KCTeam
  • 2
  • 2
5 Comments
 
LVL 7

Expert Comment

by:lucky_james
ID: 20084129
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:
http://docs.huihoo.com/ace_tao/ACE-5.4-html/html/ace/a01719.html
0
 
LVL 7

Expert Comment

by:lucky_james
ID: 20084148
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.
0
 

Author Comment

by:KCTeam
ID: 20101411
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.  
0
 

Accepted Solution

by:
KCTeam earned 0 total points
ID: 20661885
The ACE_Task_Base not taking the stack size parameter is a bug.
See http://groups.google.com/group/comp.soft-sys.ace/browse_thread/thread/2582a1e7e0bf05c4/201c59738d79139f?lnk=gst&q=stack+size#201c59738d79139f (need to expand last post)

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



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

Open in new window

0
 
LVL 1

Expert Comment

by:Vee_Mod
ID: 20697076
Closed, 500 points refunded.
Vee_Mod
Community Support Moderator
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
Suggested Courses

830 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