This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Counting amount of memory allocated?


>How do I go about disabling pool allocation that is happening for these
>containers?  Ideally I would like to be able to disable it globally with a
>single #define (such as -D__USE_MALLOC), so that I can just enable it for
>debug builds.  Do I really have to recompile libstdc++ to do this, or is
>there an easier way?

RTFM

GLIBCPP_FORCE_NEW

http://gcc.gnu.org/onlinedocs/libstdc++/ext/howto.html#3

Also, you can explicitly force "C" library bits to be de-allocated with


#include <locale>
#include <cassert>

extern "C" void __libc_freeres(void);
extern "C" int __cxa_atexit(void (*func) (void *), void *arg, void *d);

void test01()
{
  using namespace std;
  bool test = true;

  locale loc06("fr_FR");
  locale loc09(loc06, "C", locale::ctype);
  assert (loc09.name() != "fr_FR");
}

int main()
{
  // Make glibc tear down all data structures on exit.
  extern void* __dso_handle __attribute__ ((__weak__));
  __cxa_atexit((void (*) (void *)) __libc_freeres, NULL,
               &__dso_handle ? __dso_handle : NULL);

  test01();
  return 0;
}


I've been thinking of writing up a C++ debugging HOWTO.

-benjamin


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]