Check-in [4b0f43fb2f]
Not logged in
Overview

SHA1 Hash:4b0f43fb2f97fe23378ac43ee71fe8b56daa152c
Date: 2008-02-24 02:16:25
User: aku
Comment:Plugged memory leak in changeset destructor. Updated commentary. Reformatting of a few integrity checks for readability.
Timelines: ancestors | descendants | both | trunk
Other Links: files | ZIP archive | manifest

Tags And Properties
Changes
[hide diffs]

Modified tools/cvs2fossil/lib/c2f_prev.tcl from [1e64f84c5d] to [53853a44a2].

@@ -48,29 +48,33 @@
 	set mytypeobj   ::vc::fossil::import::cvs::project::rev::${cstype}
 	set mysrcid	$srcid
 	set myitems     $items
 	set mypos       {} ; # Commit location is not known yet.
 
+	foreach iid $items { lappend mytitems [list $cstype $iid] }
+
 	# Keep track of the generated changesets and of the inverse
 	# mapping from items to them.
 	lappend mychangesets   $self
 	lappend mytchangesets($cstype) $self
 	set     myidmap($myid) $self
-	foreach iid $items { lappend mytitems [list $cstype $iid] }
 
 	MapItems $cstype $items
 	return
     }
 
     destructor {
-	# The main thing is to keep track of the itemmap and remove
-	# the object from it. The lists of changesets (mychangesets,
-	# mytchangesets) are not maintained (= reduced), for the
-	# moment. We may be able to get rid of this entirely, at least
-	# for (de)construction and pass InitCSets.
+	# We may be able to get rid of this entirely, at least for
+	# (de)construction and pass InitCSets.
 
 	UnmapItems $mytype $myitems
+	unset myidmap($myid)
+
+	set pos                    [lsearch -exact $mychangesets $self]
+	set mychangesets           [lreplace       $mychangesets $pos $pos]
+	set pos                    [lsearch -exact $mytchangesets($mytype) $self]
+	set mytchangesets($mytype) [lreplace       $mytchangesets($mytype) $pos $pos]
 	return
     }
 
     method str {} {
 	set str    "<"
@@ -144,34 +148,24 @@
 
     method breakinternaldependencies {cv} {
 	upvar 1 $cv counter
 	log write 14 csets {[$self str] BID}
 	vc::tools::mem::mark
-	##
-	## NOTE: This method, maybe in conjunction with its caller
-	##       seems to be a memory hog, especially for large
-	##       changesets, with 'large' meaning to have a 'long list
-	##       of items, several thousand'. Investigate where the
-	##       memory is spent and then look for ways of rectifying
-	##       the problem.
-	##
-
-	# This method inspects the changesets for internal
-	# dependencies. Nothing is done if there are no
-	# such. Otherwise the changeset is split into a set of
-	# fragments without internal dependencies, transforming the
+
+	# This method inspects the changeset, looking for internal
+	# dependencies. Nothing is done if there are no such.
+
+	# Otherwise the changeset is split into a set of fragments
+	# which have no internal dependencies, transforming the
 	# internal dependencies into external ones. The new changesets
 	# generated from the fragment information are added to the
-	# list of all changesets.
-
-	# The code checks only successor dependencies, as this
-	# automatically covers the predecessor dependencies as well (A
+	# list of all changesets (by the caller).
+
+	# The code checks only successor dependencies, as this auto-
+	# matically covers the predecessor dependencies as well (Any
 	# successor dependency a -> b is also a predecessor dependency
 	# b -> a).
-
-	# Array of dependencies (parent -> child). This is pulled from
-	# the state, and limited to successors within the changeset.
 
 	array set breaks {}
 
 	set fragments [BreakDirectDependencies $myitems breaks]
 
@@ -219,10 +213,11 @@
 		DELETE FROM cssuccessor WHERE cid = $myid;
 	    }
 	}
 
 	UnmapItems $mytype $myitems
+	unset myidmap($myid)
 
 	set pos                    [lsearch -exact $mychangesets $self]
 	set mychangesets           [lreplace       $mychangesets $pos $pos]
 	set pos                    [lsearch -exact $mytchangesets($mytype) $self]
 	set mytchangesets($mytype) [lreplace       $mytchangesets($mytype) $pos $pos]
@@ -653,22 +648,26 @@
 
 	#puts \t.[join [PRs $fragments] .\n\t.].
 
 	Border [lindex $fragments 0] firsts firste
 
-	integrity assert {$firsts == 0} {Bad fragment start @ $firsts, gap, or before beginning of the range}
+	integrity assert {
+	    $firsts == 0
+	} {Bad fragment start @ $firsts, gap, or before beginning of the range}
 
 	set laste $firste
 	foreach fragment [lrange $fragments 1 end] {
 	    Border $fragment s e
-	    integrity assert {$laste == ($s - 1)} {Bad fragment border <$laste | $s>, gap or overlap}
+	    integrity assert {
+		$laste == ($s - 1)
+	    } {Bad fragment border <$laste | $s>, gap or overlap}
 
 	    set new [$type %AUTO% $myproject $mytype $mysrcid [lrange $myitems $s $e]]
 	    lappend newcsets $new
 	    incr counter
 
-            log write 4 csets "Breaking [$self str ] @ $laste, new [$new str], cutting $breaks($laste)"
+            log write 4 csets {Breaking [$self str ] @ $laste, new [$new str], cutting $breaks($laste)}
 
 	    set laste $e
 	}
 
 	integrity assert {
@@ -691,11 +690,15 @@
     # # ## ### ##### ######## #############
 
     proc BreakDirectDependencies {theitems bv} {
 	upvar 1 mytypeobj mytypeobj self self $bv breaks
 
+	# Array of dependencies (parent -> child). This is pulled from
+	# the state, and limited to successors within the changeset.
+
 	array set dependencies {}
+
 	$mytypeobj internalsuccessors dependencies $theitems
 	if {![array size dependencies]} {
 	    return {}
 	} ; # Nothing to break.