LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 11-12-2012, 03:50 PM   #1
linuxlinuxlinux
LQ Newbie
 
Registered: Nov 2012
Posts: 2

Rep: Reputation: Disabled
pthread : Avoiding thread specific heaps


Hi,

I notice that when I allocate heap memory (malloc) from a threads (created using pthread_create), each thread seems to be using a separate heap by default. Is it possible to change this behavior using some parameters/environment variables ? If possible, I would like to use a single heap, even if that means thread contention and slowdown due to internal locking/unlocking that may happen in allocation/free functions.

Thanks in advance!
GS

Last edited by linuxlinuxlinux; 11-12-2012 at 06:22 PM.
 
Old 11-13-2012, 04:48 AM   #2
leniviy
Member
 
Registered: Jul 2009
Distribution: Archlinux
Posts: 69

Rep: Reputation: 4
I guess, you're trying to conserve some memory space.
I've read glibc/malloc/malloc.c briefly.
It seems that the arenas are thread-specific.
Here they say that a heap is a collection of arenas (sub-heaps).

It's obvious, that you can't disable this feature at runtime.
 
1 members found this post helpful.
Old 11-13-2012, 05:54 AM   #3
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,838

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
Yes, it is not possible, but you can lower the default size of that heap.
 
1 members found this post helpful.
Old 11-13-2012, 01:12 PM   #4
linuxlinuxlinux
LQ Newbie
 
Registered: Nov 2012
Posts: 2

Original Poster
Rep: Reputation: Disabled
ok. Thanks a lot for the help !
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
fork vs thread/pthread powerplane Programming 17 08-11-2012 02:13 PM
How to bind a thread to specific thread in multithread application? h.aliee Programming 4 12-30-2010 03:11 PM
How to suspend/resume a thread when using Pthread.h h.aliee Programming 4 12-15-2010 09:13 AM
LXer: Avoiding memory leaks in POSIX thread programming LXer Syndicated Linux News 0 08-26-2010 02:20 AM
Thread pools using pthread in C duryodhan Programming 1 03-23-2008 04:56 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 08:34 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration