diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index b1bb70159c78c9550797b6df9d596d85b7abc41d..91082c7ebf2a9450d717362af36b241342b8e869 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,8 @@
+2002-05-15  Rainer Orth  <ro@TechFak.Uni-Bielefeld.DE>
+
+	* testsuite/testsuite_hooks.h (__set_testsuite_memlimit):
+	Retrieve current limits before setting.
+
 2002-05-15  Benjamin Kosnik  <bkoz@redhat.com>
 
 	PR libstdc++/6518
diff --git a/libstdc++-v3/testsuite/testsuite_hooks.h b/libstdc++-v3/testsuite/testsuite_hooks.h
index 08d93d382745e6242144db09c1a1fa32dcb0068d..eb87d51f2973b4fea0e986858939990abca1dd4a 100644
--- a/libstdc++-v3/testsuite/testsuite_hooks.h
+++ b/libstdc++-v3/testsuite/testsuite_hooks.h
@@ -81,25 +81,33 @@ void
 __set_testsuite_memlimit(float __size = MEMLIMIT_MB)
 {
     struct rlimit r;
-    r.rlim_cur = (rlim_t)(__size * 1048576);
+    rlim_t limit = (rlim_t)(__size * 1048576);
 
     // Heap size, seems to be common.
 #if _GLIBCPP_HAVE_MEMLIMIT_DATA
+    getrlimit(RLIMIT_DATA, &r);
+    r.rlim_cur = limit;
     setrlimit(RLIMIT_DATA, &r);
 #endif
 
     // Resident set size.
 #if _GLIBCPP_HAVE_MEMLIMIT_RSS
+    getrlimit(RLIMIT_RSS, &r);
+    r.rlim_cur = limit;
     setrlimit(RLIMIT_RSS, &r);
 #endif
 
     // Mapped memory (brk + mmap).
 #if _GLIBCPP_HAVE_MEMLIMIT_VMEM
+    getrlimit(RLIMIT_VMEM, &r);
+    r.rlim_cur = limit;
     setrlimit(RLIMIT_VMEM, &r);
 #endif
 
     // Virtual memory.
 #if _GLIBCPP_HAVE_MEMLIMIT_AS
+    getrlimit(RLIMIT_AS, &r);
+    r.rlim_cur = limit;
     setrlimit(RLIMIT_AS, &r);
 #endif
 }