--- a/lib/getdtab.c
+++ b/lib/getdtab.c
@@ -37,6 +37,15 @@ getfdcount()
 	if (getrlimit(RLIMIT_NOFILE, &rl) < 0)
 	    return -1;
 	size = rl.rlim_cur;
+
+	/* Modern Linux systems allow a huge number of open file descriptors,
+	 * which make innd exaust the available memory due to the static
+	 * allocation of its data structures.
+	 * Here we set a reasonable default, which if needed can be raised
+	 * by the local administrator by setting a different open files
+	 * limit for the process. See #1029152. */
+	if (size >= 1048576)
+	    size = 1024;
     }
     return size;
 }
