On the 1.9.x-r1725180 branch:
Merge r1725180 from /trunk, resolve the text conflict and make everything
compile again.


git-svn-id: https://svn.apache.org/repos/asf/subversion/branches/1.9.x-r1725180@1727684 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/subversion/libsvn_fs_fs/cached_data.c b/subversion/libsvn_fs_fs/cached_data.c
index 1618f07..948870e 100644
--- a/subversion/libsvn_fs_fs/cached_data.c
+++ b/subversion/libsvn_fs_fs/cached_data.c
@@ -2558,8 +2558,12 @@
   SVN_ERR(get_dir_contents(entries_p, fs, noderev, result_pool,
                            scratch_pool));
 
-  /* Update the cache, if we are to use one. */
-  if (cache)
+  /* Update the cache, if we are to use one.
+   *
+   * Don't even attempt to serialize very large directories; it would cause
+   * an unnecessary memory allocation peak.  150 bytes/entry is about right.
+   */
+  if (cache && svn_cache__is_cachable(cache, 150 * (*entries_p)->nelts))
     SVN_ERR(svn_cache__set(cache, key, *entries_p, scratch_pool));
 
   return SVN_NO_ERROR;