diff -ur '--exclude=po' davfs2-1.4.7/etc/davfs2.conf davfs2-1.4.7-min-mem/etc/davfs2.conf
--- davfs2-1.4.7/etc/davfs2.conf	2013-02-17 10:33:57.000000000 +0100
+++ davfs2-1.4.7-min-mem/etc/davfs2.conf	2013-02-17 10:36:34.000000000 +0100
@@ -62,6 +62,7 @@
 # file_refresh    1                 # second
 # delay_upload    10
 # gui_optimize    0
+# minimize_mem    0
 
 # Debugging Options
 # -----------------
diff -ur '--exclude=po' davfs2-1.4.7/src/cache.c davfs2-1.4.7-min-mem/src/cache.c
--- davfs2-1.4.7/src/cache.c	2013-02-17 10:33:57.000000000 +0100
+++ davfs2-1.4.7-min-mem/src/cache.c	2013-02-20 20:57:37.000000000 +0100
@@ -168,6 +168,13 @@
    GET If-Modified-Since for single files. */
 static int gui_optimize;
 
+/* Remove nodes that are currently not needed to minimize memory usage. */
+static int minimize_mem;
+
+/* When to next run minimize_tree. 0 means to not run minimize_tree.
+   Must be updated when a node is created. */
+static time_t next_minimize;
+
 /* Time interval to wait, before a directory is updated. Usually equal to
    dir_refresh, but will be varied in case the connection timed out.*/
 static time_t retry;
@@ -276,6 +283,9 @@
     return item->save_at;
 }
 
+static void
+minimize_tree(dav_node *node);
+
 static int
 move_dir(dav_node *src, dav_node *dst, dav_node *dst_parent,
          const char *dst_name);
@@ -604,6 +614,7 @@
     file_refresh = args->file_refresh;
     delay_upload = args->delay_upload;
     gui_optimize = args->gui_optimize;
+    minimize_mem = args->minimize_mem;
     retry = dir_refresh;
     min_retry = args->retry;
     max_retry = args->max_retry;
@@ -648,6 +659,7 @@
     backup->mode = S_IFDIR | S_IRWXU;
 
     clean_cache();
+    next_minimize = 0;
 
     int ret = update_directory(root, 0);
     if (ret == EAGAIN) {
@@ -751,6 +763,16 @@
     if (cache_size > max_cache_size)
         resize_cache();
 
+    if (minimize_mem && next_minimize && time(NULL) > next_minimize) {
+        if (debug)
+            syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), "minimize_tree");
+        next_minimize = 0;
+        minimize_tree(root);
+        if (debug)
+            syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG),
+                    "minimize_tree: %llu nodes remaining", fs_stat->files);
+    }
+
     static dav_node_list_item *item = NULL;
 
     dav_node_list_item *next_item = changed;
@@ -1848,6 +1870,44 @@
 }
 
 
+/* Removes file nodes that are currently not needed to minimize
+   memory usage. */
+static void
+minimize_tree(dav_node *node)
+{
+    if (node == backup) return;
+
+    if (is_dir(node)) {
+
+        int rm = !is_open(node)
+                    && (time(NULL) > (node->utime + 2 * file_refresh))
+                    && (time(NULL) > (node->atime + 2 * file_refresh));
+        dav_node *child = node->childs;
+        while (child) {
+            dav_node *next = child->next;
+            if (rm || is_dir(child)) {
+                minimize_tree(child);
+            } else if (next_minimize == 0) {
+                next_minimize = time(NULL) + 2 * file_refresh;
+            }
+            child = next;
+        }
+
+    } else if (!is_cached(node) && !is_locked(node) && !is_created(node)) {
+
+        remove_from_tree(node);
+        remove_from_table(node);
+        delete_node(node);
+        *flush = 1;
+
+    } else if (next_minimize == 0) {
+
+        next_minimize = time(NULL) + file_refresh;
+
+    }
+}
+
+
 /* Moves directory src to dst using WebDAV method MOVE. */
 static int
 move_dir(dav_node *src, dav_node *dst, dav_node *dst_parent,
@@ -2071,6 +2131,9 @@
         syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), "new node: %p->%p",
                node->parent, node);
     fs_stat->files++;
+    if (next_minimize == 0)
+        next_minimize = node->atime + file_refresh;
+
     return node;
 }
 
diff -ur '--exclude=po' davfs2-1.4.7/src/defaults.h davfs2-1.4.7-min-mem/src/defaults.h
--- davfs2-1.4.7/src/defaults.h	2013-02-17 10:33:57.000000000 +0100
+++ davfs2-1.4.7-min-mem/src/defaults.h	2013-02-17 10:36:34.000000000 +0100
@@ -101,6 +101,9 @@
    May be overridden by system config file and user config file. */
 #define DAV_GUI_OPTIMIZE 0
 
+/* Remove nodes that are currently not needed to minimize memory usage. */
+#define DAV_MINIMIZE_MEM 0
+
 
 /* HTTP */
 /*======*/
diff -ur '--exclude=po' davfs2-1.4.7/src/mount_davfs.c davfs2-1.4.7-min-mem/src/mount_davfs.c
--- davfs2-1.4.7/src/mount_davfs.c	2013-02-17 10:33:57.000000000 +0100
+++ davfs2-1.4.7-min-mem/src/mount_davfs.c	2013-02-17 10:36:34.000000000 +0100
@@ -1779,6 +1779,7 @@
     args->file_refresh = DAV_FILE_REFRESH;
     args->delay_upload = DAV_DELAY_UPLOAD;
     args->gui_optimize = DAV_GUI_OPTIMIZE;
+    args->minimize_mem = DAV_MINIMIZE_MEM;
 
     args->debug = 0;
     args->neon_debug = 0;
@@ -2215,6 +2216,8 @@
                 args->delay_upload = arg_to_int(parmv[1], 10, parmv[0]); 
             } else if (strcmp(parmv[0], "gui_optimize") == 0) {
                 args->gui_optimize = arg_to_int(parmv[1], 10, parmv[0]); 
+            } else if (strcmp(parmv[0], "minimize_mem") == 0) {
+                args->minimize_mem = arg_to_int(parmv[1], 10, parmv[0]); 
             } else if (strcmp(parmv[0], "debug") == 0) {
                 args->debug |= debug_opts(parmv[1]);
                 args->neon_debug |= debug_opts_neon(parmv[1]);
diff -ur '--exclude=po' davfs2-1.4.7/src/mount_davfs.h davfs2-1.4.7-min-mem/src/mount_davfs.h
--- davfs2-1.4.7/src/mount_davfs.h	2013-02-17 10:33:57.000000000 +0100
+++ davfs2-1.4.7-min-mem/src/mount_davfs.h	2013-02-17 10:36:34.000000000 +0100
@@ -94,6 +94,7 @@
     time_t file_refresh;      /* User config file, system config file */
     int delay_upload;         /* User config file, system config file */
     int gui_optimize;         /* User config file, system config file */
+    int minimize_mem;         /* User config file, system config file */
     /* Debugging */
     int debug;                /* User config file, system config file */
     int neon_debug;           /* User config file, system config file */
