Author: stsp Date: Tue Jul 19 21:51:21 2011 New Revision: 1148566 URL: http://svn.apache.org/viewvc?rev=1148566&view=rev Log: Fix a memory leak observed during a merge which involves a lot of subtree mergeinfo on long-lived branches.
Reported by me in #svn-dev today: [15:31] <stsp> pburba, running svn merge ^/subversion/trunk in a WC of the gpg-agent-password-store branch @1148391 results in over 300MB of memory allocated http://colabti.org/irclogger/irclogger_log/svn-dev?date=2011-07-19#l115 With this fix memory use stays constant at around 20MB throughout the merge. The merge is also very slow but that is an unrelated problem and will be fixed later. * subversion/libsvn_client/merge.c (log_noop_revs): The baton's pool is used in an iterpool pattern so it must be cleared on each invocation of this function. (remove_noop_subtree_ranges): Make the baton's pool a proper subpool to avoid clearing unrelated data in log_noop_revs(). Modified: subversion/trunk/subversion/libsvn_client/merge.c Modified: subversion/trunk/subversion/libsvn_client/merge.c URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/merge.c?rev=1148566&r1=1148565&r2=1148566&view=diff ============================================================================== --- subversion/trunk/subversion/libsvn_client/merge.c (original) +++ subversion/trunk/subversion/libsvn_client/merge.c Tue Jul 19 21:51:21 2011 @@ -7889,6 +7889,18 @@ log_noop_revs(void *baton, apr_hash_index_t *hi; svn_revnum_t revision; svn_boolean_t log_entry_rev_required = FALSE; + apr_array_header_t *rl1; + apr_array_header_t *rl2; + + /* The baton's pool is essentially an iterpool so we must clear it + * for each invocation of this function. */ + rl1 = svn_rangelist_dup(log_gap_baton->operative_ranges, pool); + rl2 = svn_rangelist_dup(log_gap_baton->merged_ranges, pool); + svn_pool_clear(log_gap_baton->pool); + log_gap_baton->operative_ranges = svn_rangelist_dup(rl1, + log_gap_baton->pool); + log_gap_baton->merged_ranges = svn_rangelist_dup(rl2, + log_gap_baton->pool); revision = log_entry->revision; @@ -8116,7 +8128,7 @@ remove_noop_subtree_ranges(const char *u result_pool, scratch_pool)); log_gap_baton.merged_ranges = merged_ranges; log_gap_baton.operative_ranges = operative_ranges; - log_gap_baton.pool = scratch_pool; + log_gap_baton.pool = svn_pool_create(scratch_pool); APR_ARRAY_PUSH(log_targets, const char *) = "";
