""/> making STL use " __malloc_alloc_template<0> "
niXforums Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   PreferencesPreferences   Log in to check your private messagesLog in to check your private messages   Log inLog in 
·  nixdoc.net ·  man pages ·  Linux HOWTOs ·  FreeBSD Tips ·  Forums
navigation Forum index » Programming » C++
making STL use " __malloc_alloc_template<0> "
Post new topic   Reply to topic Page 1 of 1 [2 Posts] View previous topic :: View next topic
Author Message
jithoosin
*nix forums beginner


Joined: 21 Jul 2006
Posts: 6

PostPosted: Fri Jul 21, 2006 6:23 am    Post subject: making STL use " __malloc_alloc_template<0> " Reply with quote

Hi

I am using STL in my code. So after some time it appears as if the
code is leaking memory. I did a memory profiling using valgrind massif
to find out that most memory in my code is allocated using the 2
functions

1) std::__default_alloc_template<true, 0>::allocate(unsigned) (in
/usr/lib/libstdc++.so.5.0.3)
2) std::__default_alloc_template<true, 0>::_S_chunk_alloc(unsigned,
int&) (in /usr/lib/libstdc++.so.5.0.3)

When i googled i found a useful reference:
http://www-1.ibm.com/support/docview.wss?rs=994&context=SSSHAD&dc=DB5...

It asks me to use __malloc_alloc_template<0> in my code so that STL
"actualy frees" memory. So I have 3 questions .
1) Would this strategy be helpful ?
2) Is there any easy way to make my code use this template by any
options rather than changing the code as the link suggests ?
3) How this allocator can be used with a map ?

Thanks in advance.

Regards
Kiran Pradeep
Back to top
joosteto@gmail.com
*nix forums beginner


Joined: 09 Jul 2006
Posts: 20

PostPosted: Fri Jul 21, 2006 7:42 am    Post subject: Re: making STL use " __malloc_alloc_template<0> " Reply with quote

jithoosin wrote:
Quote:
Hi

I am using STL in my code. So after some time it appears as if the
code is leaking memory. I did a memory profiling using valgrind massif
to find out that most memory in my code is allocated using the 2
functions

1) std::__default_alloc_template<true, 0>::allocate(unsigned) (in
/usr/lib/libstdc++.so.5.0.3)
2) std::__default_alloc_template<true, 0>::_S_chunk_alloc(unsigned,
int&) (in /usr/lib/libstdc++.so.5.0.3)

When i googled i found a useful reference:
http://www-1.ibm.com/support/docview.wss?rs=994&context=SSSHAD&dc=DB520&uid=swg21160634&loc=en_US&cs=UTF-8&lang=en

It asks me to use __malloc_alloc_template<0> in my code so that STL
"actualy frees" memory. So I have 3 questions .
1) Would this strategy be helpful ?

The page you link to doesn't "ask you to use __malloc_alloc_template",
it merely states that if you do it, then your program will start to
call the free() function. But it also explains that there is really no
point in doing so, as there is no memory leak -- just that at
destruction of the object, the memory is put on the 'cache ready for
re-use' without a call to free().
So if your program is really leaking memory, it isn't because of this.
(valgrind may be complaining because of it, but it isn't an actual
memory leak)

Quote:
3) How this allocator can be used with a map ?

I just tried to compile the example code provided by IBM, but even the
vector example didn't compile for me. They are probably describing a
different gcc version (I just tried with 3.4.4).

Anyway, I suppose the question is 'off topic' officially, as it's got
more to do with the actual implementation of how g++ allocates/frees
memory than with any C++ standard.

Your actual problem on the other hand may well be on-topic here (the
memory leak itself).

Thanks.
Back to top
Google

Back to top
Display posts from previous:   
Post new topic   Reply to topic Page 1 of 1 [2 Posts] View previous topic :: View next topic
The time now is Sun Nov 23, 2008 1:47 pm | All times are GMT
navigation Forum index » Programming » C++
Jump to:  

Similar Topics
Topic Author Forum Replies Last Post
No new posts Urgent and imp. Making Squid 2.6 stable as tranpsarent proxy SHERDIL Squid 0 Thu Aug 03, 2006 11:18 am
No new posts Help required for making squid 2.6 stable 2 transparent SHERDIL Squid 0 Tue Aug 01, 2006 6:55 am
No new posts Help required for making squid 2.6 stable 2 transparent SHERDIL Squid 0 Tue Aug 01, 2006 6:52 am
No new posts making STL use " __malloc_alloc_template<0> " jithoosin C++ 1 Fri Jul 21, 2006 6:03 am
No new posts making the proxy and/or rewrite mods respond to a particu... Mike Soultanian Apache 1 Tue Jul 18, 2006 9:46 pm

Jorge Bucay | Advertising | Internet Advertising | Discount Magazines | Loans
Copyright © 2004-2005 DeniX Solutions SRL
 
Other DeniX Solutions sites: Unix/Linux blog |  electronics forum |  medicine forum |  science forum | 
Privacy Policy


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.2584s ][ Queries: 16 (0.0946s) ][ GZIP on - Debug on ]