title: 64-bit C++ binary consumes huge memory even binary size is huge
body: <p>When we compiled our C++ apps in 32-bit everything was still ok.  When we ported everything to 64-bit the binary sizes more than doubled! And when we ran the binaries, only one ran because it was hogging all the RAM. We've done all the 64-bit porting so that compilation is successful. However, during runtime, the memory consumption goes up to the limit.  It doesn't crash though. It just runs until it stops and no core file is generated.  Does anyone have any suggestion where I should start in investigating this?</p>
  
  <p>Our compilation options are:</p>
  
  <blockquote>
    <p>-D_<em>linux</em>_ -pthread -fexceptions -c -Wall -DSTL_HAS_DEFAULT_ARGS -DUsePthread -D_REENTRANT
    -Dx86_64 -DLINUX  -g  -O2</p>
  </blockquote>
  
  <p>The ulimit info on our linux machine is:</p>
  
  <pre><code>-bash-4.1$ ulimit -a
  core file size          (blocks, -c) unlimited
  data seg size           (kbytes, -d) unlimited
  scheduling priority             (-e) 0
  file size               (blocks, -f) unlimited
  pending signals                 (-i) 30405
  max locked memory       (kbytes, -l) 64
  max memory size         (kbytes, -m) unlimited
  open files                      (-n) 4096
  pipe size            (512 bytes, -p) 8
  POSIX message queues     (bytes, -q) 819200
  real-time priority              (-r) 0
  stack size              (kbytes, -s) 4096
  cpu time               (seconds, -t) unlimited
  max user processes              (-u) 10240
  virtual memory          (kbytes, -v) unlimited
  file locks                      (-x) unlimited
  </code></pre>
  
  <p>Our 24 binaries create in total about 4000 threads (thus the -u 10240) created mostly for message listening purposes.
  It also constantly searches/maintains db connection.
  The stack size -s was 512 before but we changed to 4096 just to try out but still have the problem.
  This may also probably be a memory leak that we need to fix because of some undetected logical error when porting to 64-bit but I'm not sure where to start.
  Any suggestions on how to tackle this?</p>
  
  <p>Compiler: g++ (GCC) 4.4.7 20120313 (Red Hat 4.4.7-3)
  OS:  CentOS release 6.4</p>