Re: memory use increasing while running, till...

new topic     » goto parent     » topic index » view thread      » older message » newer message
mattlewis said...
DerekParnell said...

So, the problem lies with the interaction of the reverse() and replace() calls. Without looking at the IL code yet, it looks like a dereference is being skipped for some reason.

The problem manifests translated, too. The memory being leaked is allocated inside of sequence.e reverse:

 
	for lowr = pFrom to lLimit do 
		t[uppr] = target[lowr] -- << this line! 
		t[lowr] = target[uppr] 
		uppr -= 1 
	end for 

It happens when we copy the sequence due to a non-unique reference count. From a valgrind session on a translated version:

==4997== 7,543,928 bytes in 134,713 blocks are definitely lost in loss record 192 of 192 
==4997==    at 0x4C2B3F8: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) 
==4997==    by 0x40E44C: EMalloc (be_alloc.c:1065) 
==4997==    by 0x40DEAE: NewS1 (be_alloc.c:830) 
==4997==    by 0x40E0AD: SequenceCopy (be_alloc.c:894) 
==4997==    by 0x405494: _2reverse (sequence.c:121) 
==4997==    by 0x40482F: main (main-.c:310) 

Next step is to figure out why it's not being freed...

Matt

How about try using a free(target) at the end of the reverse() function
just before the return t

just to see if it has something to do with multiple copies of target

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu