From: Jason Deines (roller@leland.Stanford.EDU)
Date: 05/14/93


From: roller@leland.Stanford.EDU (Jason Deines)
Subject: possible memory leak in libc 4.3.3 iostreams?
Date: 14 May 1993 07:19:23 GMT


The following sample program illustrates a memory leak, at least on my
system (gcc 4.3.3, libc 4.3.3, kernel.99 PL9) The problem appears to be
the overloaded << operator for floats and doubles; ints, longs, and
character strings seem to be fine. I just grabbed the sources and will
be looking at them over the next few days, but I was wondering if anyone
had come across this problem before and (ideally) what might be done to
correct it. I am working on an application that writes out a lot of
floating point numbers, and this is causing my code to die horrible,
VM-starved deaths...

Any advice would be most appreciated -- email or posting is fine.
Thanks.

Jason Deines
roller@saffron.stanford.edu

=============

#include <iostream.h>
#include <fstream.h>

int main() {
  ofstream outfile;
  int i;
  char t = ' ';
  float value = 123.1;

  outfile.open("test.out");

  for (i = 0; i < 1000000; i++)
    outfile << value << t << value << t << value << endl;

  outfile.close();
  return (0);
}