+ /* Choose a suitable memory size (in MB). This is more art
+ * than science, but you can help by doing
+ * ./configure --enable-debug-command
+ * and then running:
+ * debug sh free
+ * debug mem ''
+ * and seeing how much free memory is left for particular
+ * configurations.
+ *
+ * It's also helpful to report both the compressed and uncompressed
+ * size of the initramfs (ls -lh initramfs*.img; du -sh initramfs).
+ *
+ * XXX KVM virtio balloon driver?
+ */
+ if (stat (initrd, &statbuf) != -1) {
+ /* Approximate size of the initramfs after it is decompressed
+ * in kernel memory. The compression factor is ~2.5-3.
+ */
+ memsize = 3 * statbuf.st_size / 1024 / 1024;
+
+ /* Approximate size used by the kernel. */
+ memsize += 10;
+
+ /* Want to give userspace some room, so: */
+ memsize += 128;
+
+#if AC_SIZEOF_LONG == 8
+ /* On 64 bit, assume some overhead. */
+ memsize += 32;
+#endif
+ } else
+ memsize = 512;
+
+