John Gerdeman on Sat, 30 Aug 2008 19:21:14 +0200


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Garbage Collection of Lists


When running the following two Tests on build 2.3.2 to 2.4.1 the memory
usage stays constant. When I run it on 2.4.2 (developement) the memory
usage increases constantly.

In both Tests lists of length X are created and for each position in
that list we loop over the integers from 0 to X.

In Test1 we do this by passing the list as parameter and copying it.

In Test2 we use a global list, that is to be filled.

(I am trying to find certain polynomials and the elements of the list
represent its coefficients. In case you wondered what I was doing).

Since I have no problem restricting myself to Version 2.3.2, the
constant memory increase does not bother me. 

I was just curious to know, if this behaviour was intended or not.

John Gerdeman
/*
 * Test Garbage Collection of Lists
 */

/*Define globals, that are used in the tests*/
length_=10;
list2_=0;
/*
 * Test 1
 *
 * hand over the list as parameter and make a copy to work with.
 */
loop1(list_, k_)={
	local(locList);
	locList=list_;
	if((k_<(length_+1)),
		for(X=1,length_,
			listput(locList,X,k_);
			loop1(locList, k_+1);
		);
	);
}

Test1(X)={
	length_=X;
	list=listcreate(length_);
	loop1(list,1);
}

/*
 * Test 2
 *
 * Use a global list, and fill it.
 */
loop2(k_)={
	if((k_<(length_+1)),
		for(X=1,length_,
			listput(list2_,X,k_);
			loop2(k_+1);
		);
	);
}

Test2(X)={
	length_=X;
	list2_=listcreate(length_);
	loop2(1);
}