public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: excessive memory consumption
@ 1997-10-03 17:03 Mike Stump
  0 siblings, 0 replies; 12+ messages in thread
From: Mike Stump @ 1997-10-03 17:03 UTC (permalink / raw)
  To: egcs, jason, jbuck

Awesome!  Thanks Jason!

^ permalink raw reply	[flat|nested] 12+ messages in thread
* Re: excessive memory consumption
@ 1997-10-05 18:08 Corey Kosak
  0 siblings, 0 replies; 12+ messages in thread
From: Corey Kosak @ 1997-10-05 18:08 UTC (permalink / raw)
  To: jason, jbuck, egcs

The following program still takes nearly 200M of memory to compile,
even with Jason Merrill's October 3 patch.

% gcc -v
Reading specs from /afs/cs/project/cmcl-kosak/patchloco/lib/gcc-lib/alpha-dec-osf3.2/egcs-2.90.11/specs
gcc version egcs-2.90.11 970929 (gcc2-970802 experimental)
% cat crack.cc
#include <vector>

class foo_t {
public:
  vector<int> v;
};

class bar_t {
public:
  vector<foo_t> bar;
};

int main()
{
  bar_t bar;
}
% limit datasize 200M
% g++ -O2 -Wall crack.cc
/bin/ld:
Warning: Linking some objects which contain exception information sections
        and some which do not. This may cause fatal runtime exception handling
        problems (last obj encountered without exceptions was /afs/cs/project/cmcl-kosak/patchloco/lib/libstdc++.a).
/bin/ld:
Warning: Linking some objects which contain exception information sections
        and some which do not. This may cause fatal runtime exception handling
        problems (last obj encountered without exceptions was /afs/cs/project/cmcl-kosak/patchloco/lib/libstdc++.a).
% limit datasize 195M
% g++ -O2 -Wall crack.cc
crack.cc: In function `int main()':
crack.cc:16: virtual memory exhausted

^ permalink raw reply	[flat|nested] 12+ messages in thread
[parent not found: <199709300033.RAA17703.cygnus.egcs@atrus.synopsys.com>]
* excessive memory consumption
@ 1997-09-29 17:33 Joe Buck
  1997-09-29 19:14 ` Joe Buck
  1997-09-30  5:52 ` Jan Springer
  0 siblings, 2 replies; 12+ messages in thread
From: Joe Buck @ 1997-09-29 17:33 UTC (permalink / raw)
  To: egcs team

The attached program, when built with

c++ -O tdeque.cxx -o tdeque

builds correctly, but needs 492 megabytes of virtual memory to build on a
Sparc.  Fortunately, I was using a server with gobs of memory.  That's,
um, impressive.  I haven't whipped out purify, but there's got to be some
kind of leak here (or tons of unneeded stuff is kept around?).

The program attempts to do thorough tests of three different expansions
of deque<T>: deque<double>, deque<string>, and deque<pair<int,int> >,
using one test template.

---------------- cut here ---------------------
#include <string>
#include <deque>
#include <utility>
#include <iostream.h>
#include <algorithm>

inline const char* yn(bool ans) { return ans ? "yes" : "no";}

template<class A,class B>
ostream& operator<<(ostream& o, const pair<A,B>& p)
{
    o << '(' << p.first << ',' << p.second << ')';
    return o;
}

template<class T>
void show_d(const char* label, const deque<T>& data)
{
    cout << label;
    copy(data.begin(), data.end(), ostream_iterator<T>(cout, " "));
    cout << endl;
}

// val1, val2, val3 should be three distinct values, all different from the
// default constructor value T().

template<class T>
void deque_test(const T& val1, const T& val2, const T& val3)
{
    cout << "val1 = " << val1 << ", val2 = " << val2 << ", val3 = "
	 << val3 << endl;
    // test basic contructors
    deque<T> dq1;
    show_d("empty deque: ", dq1);
    cout << "empty? " << dq1.empty() << ", size? " << dq1.size() << endl;
    deque<T> dq2(5);
    show_d("default deque of 5 elements: ", dq2);
    cout << "empty? " << dq2.empty() << ", size? " << dq2.size() << endl;
    deque<T> dq3(4, val1);
    show_d("four elements of val1: ", dq3);
    deque<T> dq4(dq3);
    show_d("copy ctor: ", dq4);
    // test push_back and push_front
    dq1.push_back(val1);
    dq1.push_back(val2);
    dq1.push_front(val3);
    cout << "push back: " << val1 << endl;
    cout << "push back: " << val2 << endl;
    cout << "push front: " << val3 << endl;
    show_d("dq1 with the three values: ", dq1);

    // test compares:
    cout << "dq1 == dq3? " << yn(dq1 == dq3) << endl;
    cout << "dq1 < dq3? " << yn(dq1 < dq3) << endl;
    cout << "dq3 < dq1? " << yn(dq3 < dq1) << endl;
    cout << "dq1 == dq1? " << yn(dq1 == dq1) << endl;
    cout << "dq1 < dq1? " << yn(dq1 < dq1) << endl;

    // test member template ctor and reverse iterators
    deque<T> dq5(dq1.rbegin(), dq1.rend());
    show_d("dq5: should reverse dq1: ", dq5);
    // save value
    deque<T> dq6(dq5);
    // use indexing.
    for (unsigned i = 0; i < dq1.size(); i++)
	dq5[i] = dq1[i];
    show_d("dq5 after index copy: ", dq5);
    // restore value. (test assignment op)
    dq5 = dq6;
    show_d("dq5 restored: ", dq5);
    // swap
    dq5.swap(dq3);
    show_d("dq5 after swap with dq3: ", dq5);
    show_d("dq3 after swap with dq5: ", dq3);
    cout << "dq3 front: " << dq3.front() << ", dq3 back: " << dq3.back() << endl;
    // insertion tests.
    deque<T> dq7;
    dq7.insert(dq7.begin(), val1);
    dq7.insert(dq7.begin(), 3, val2);
    dq7.insert(dq7.end(), val3);
    show_d("dq7: ", dq7);
    typename deque<T>::iterator iter1 = find(dq7.begin(), dq7.end(), val1);
    dq7.erase(iter1);
    show_d("dq7 after erasing first val1 value: ", dq7);
    dq7.pop_back();
    show_d("dq7 after pop_back: ", dq7);
    dq7.pop_front();
    show_d("dq7 after pop_front: ", dq7);
    copy(dq5.begin(), dq5.end(), back_inserter(dq7));
    show_d("dq7 with dq5 appended: ", dq7);
    copy(dq5.begin(), dq5.end(), front_inserter(dq6));
    show_d("dq6 with dq5 prepended: ", dq6);
    sort(dq7.begin(), dq7.end());
    show_d("sorted dq7: ", dq7);
    dq7.resize(dq7.size() + 2);
    show_d("dq7 extended by 2: ", dq7);
    dq7.resize(dq7.size() + 2, val3);
    show_d("dq7 extended and filled with val3: ", dq7);
    dq7.clear();
    show_d("dq7 after clear: ", dq7);
}

int main() {
    deque_test(1.2, 2.3, 3.5);
    deque_test(string("alpha"), string("beta"), string("gamma"));
    deque_test(make_pair(1,2), make_pair(2,3), make_pair(3,5));
}
---------------- cut here ---------------------

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~1997-10-06  8:29 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-10-03 17:03 excessive memory consumption Mike Stump
  -- strict thread matches above, loose matches on Subject: below --
1997-10-05 18:08 Corey Kosak
     [not found] <199709300033.RAA17703.cygnus.egcs@atrus.synopsys.com>
1997-10-03 12:01 ` Jason Merrill
1997-10-03 15:44   ` Joe Buck
1997-10-04 13:54   ` Manfred Hollstein
1997-10-05 11:07     ` Manfred Hollstein
1997-09-29 17:33 Joe Buck
1997-09-29 19:14 ` Joe Buck
1997-09-29 20:22   ` Ross Alexander
1997-09-30  5:52 ` Jan Springer
1997-09-30  6:01   ` Jan Springer
1997-10-06  8:29     ` Jan Springer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).