Skip to main content.
home | support | download

Back to List Archive

RE: Memory Leak with Sort Parameters including swishrank

From: Windmueller, David <DWindmueller(at)not-real.bloomberg.com>
Date: Wed Jul 07 2004 - 12:25:47 GMT
Round 2!
I recompiled my Swish-e with memstats and memtrace and saw the errors

Here is the source code with the slight mods for memory stats 

After the source code, I have the text from the runs.

I'm seeing that the memory from LoadSortedProps isn't getting free properly.  

Looking at why....

-David

-----------------------------
#include <stdio.h>
#include "swish-e.h"

int main () {

	SW_HANDLE myHandle = NULL;
	SW_SEARCH mySearch = NULL;
	SW_RESULTS myResults = NULL;
      int i;

	/* Swish-e Setup */
	myHandle = SwishInit ("foo.index");
	
	if (!myHandle) {
		printf("Unable to Create Handle\n");
		exit(1);
	}

	if ( SwishError(myHandle) ) {
		printf ("Swish Init Error %s\n", SwishErrorString(myHandle) );
		exit(1);
	}

	mySearch = New_Search_Object(myHandle,"");

	if (!mySearch) {
		printf("Unable to Create Search Object\n");
		exit(1);
	}
	SwishSetSort(mySearch, "swishrank swishtitle");      /* Bad Sort */ 
	/*SwishSetSort(mySearch, "swishtitle swishrank");*/  /* Good Sort */
	
      i=0;
	sleep(5);
	Mem_Summary("Before Queries",0);
	while (i<5) {
		myResults = SwishExecute(mySearch, "David Martin");
		printf("%d Hits %d\n", i,SwishHits(myResults));
		Mem_Summary("After Query",0);
		sleep(2);
		Free_Results_Object(myResults);
		Mem_Summary("After Result Free",0);
		printf("Freed\n");

		sleep(2);
		i++;
	}
	
	Free_Search_Object(mySearch);
	
      SwishClose (myHandle);
	Mem_Summary("After SwishClose",1);

	sleep(3);
}

---------------------------------


BAD RUN OUTPUT - "swishrank swishtitle"


Memory usage summary: Before Queries

Alloc calls: 382, Realloc calls: 105, Free calls: 157
Requested: Maximum usage: 875753, Current usage: 875000
Estimated: Maximum usage: 876272, Current usage: 875544
0 Hits 125

Memory usage summary: After Query

Alloc calls: 499, Realloc calls: 106, Free calls: 223
Requested: Maximum usage: 15105586, Current usage: 11281298
Estimated: Maximum usage: 15106128, Current usage: 11281840
Zone 'resultSearch Zone':
  Chunks:20, Allocs:37250, Used:5229720, Free:12040, Wasted:1120
Zone 'resultSort Zone':
  Chunks:0, Allocs:0, Used:0, Free:0, Wasted:0

Memory usage summary: After Result Free

Alloc calls: 499, Realloc calls: 106, Free calls: 273
Requested: Maximum usage: 15105586, Current usage: 5997384
Estimated: Maximum usage: 15106128, Current usage: 5997916
Freed
1 Hits 125

Memory usage summary: After Query

Alloc calls: 616, Realloc calls: 107, Free calls: 339
Requested: Maximum usage: 20227958, Current usage: 16403670
Estimated: Maximum usage: 20228500, Current usage: 16404212
Zone 'resultSearch Zone':
  Chunks:20, Allocs:37250, Used:5229720, Free:12040, Wasted:1120
Zone 'resultSort Zone':
  Chunks:0, Allocs:0, Used:0, Free:0, Wasted:0

Memory usage summary: After Result Free

Alloc calls: 616, Realloc calls: 107, Free calls: 389
Requested: Maximum usage: 20227958, Current usage: 11119756
Estimated: Maximum usage: 20228500, Current usage: 11120288
Freed
2 Hits 125

Memory usage summary: After Query

Alloc calls: 733, Realloc calls: 108, Free calls: 455
Requested: Maximum usage: 25350330, Current usage: 21526042
Estimated: Maximum usage: 25350872, Current usage: 21526584
Zone 'resultSearch Zone':
  Chunks:20, Allocs:37250, Used:5229720, Free:12040, Wasted:1120
Zone 'resultSort Zone':
  Chunks:0, Allocs:0, Used:0, Free:0, Wasted:0

Memory usage summary: After Result Free

Alloc calls: 733, Realloc calls: 108, Free calls: 505
Requested: Maximum usage: 25350330, Current usage: 16242128
Estimated: Maximum usage: 25350872, Current usage: 16242660
Freed
3 Hits 125

Memory usage summary: After Query

Alloc calls: 850, Realloc calls: 109, Free calls: 571
Requested: Maximum usage: 30472702, Current usage: 26648414
Estimated: Maximum usage: 30473244, Current usage: 26648956
Zone 'resultSearch Zone':
  Chunks:20, Allocs:37250, Used:5229720, Free:12040, Wasted:1120
Zone 'resultSort Zone':
  Chunks:0, Allocs:0, Used:0, Free:0, Wasted:0

Memory usage summary: After Result Free

Alloc calls: 850, Realloc calls: 109, Free calls: 621
Requested: Maximum usage: 30472702, Current usage: 21364500
Estimated: Maximum usage: 30473244, Current usage: 21365032
Freed
4 Hits 125

Memory usage summary: After Query

Alloc calls: 967, Realloc calls: 110, Free calls: 687
Requested: Maximum usage: 35595074, Current usage: 31770786
Estimated: Maximum usage: 35595616, Current usage: 31771328
Zone 'resultSearch Zone':
  Chunks:20, Allocs:37250, Used:5229720, Free:12040, Wasted:1120
Zone 'resultSort Zone':
  Chunks:0, Allocs:0, Used:0, Free:0, Wasted:0

Memory usage summary: After Result Free

Alloc calls: 967, Realloc calls: 110, Free calls: 737
Requested: Maximum usage: 35595074, Current usage: 26486872
Estimated: Maximum usage: 35595616, Current usage: 26487404
Freed

Memory usage summary: After SwishClose

Alloc calls: 967, Realloc calls: 110, Free calls: 963
Requested: Maximum usage: 35595074, Current usage: 20489488
Estimated: Maximum usage: 35595616, Current usage: 20489488

Unfreed memory: After SwishClose

Unfreed: ../../swish-e-2.4.2/src/result_sort.c line 246: Size: 5122372 Counter: 605
Unfreed: ../../swish-e-2.4.2/src/result_sort.c line 246: Size: 5122372 Counter: 723
Unfreed: ../../swish-e-2.4.2/src/result_sort.c line 246: Size: 5122372 Counter: 841
Unfreed: ../../swish-e-2.4.2/src/result_sort.c line 246: Size: 5122372 Counter: 959
Total Unfreed size: 20489488


------------------------------------------------

GOOD RUN TEXT - "swishtitle swishrank"



Memory usage summary: Before Queries

Alloc calls: 382, Realloc calls: 105, Free calls: 157
Requested: Maximum usage: 875753, Current usage: 875000
Estimated: Maximum usage: 876272, Current usage: 875544
0 Hits 125

Memory usage summary: After Query

Alloc calls: 499, Realloc calls: 106, Free calls: 223
Requested: Maximum usage: 15105086, Current usage: 11281298
Estimated: Maximum usage: 15105628, Current usage: 11281840
Zone 'resultSearch Zone':
  Chunks:20, Allocs:37250, Used:5229720, Free:12040, Wasted:1120
Zone 'resultSort Zone':
  Chunks:0, Allocs:0, Used:0, Free:0, Wasted:0

Memory usage summary: After Result Free

Alloc calls: 499, Realloc calls: 106, Free calls: 273
Requested: Maximum usage: 15105086, Current usage: 5997384
Estimated: Maximum usage: 15105628, Current usage: 5997916
Freed
1 Hits 125

Memory usage summary: After Query

Alloc calls: 614, Realloc calls: 107, Free calls: 338
Requested: Maximum usage: 15105086, Current usage: 11281298
Estimated: Maximum usage: 15105628, Current usage: 11281840
Zone 'resultSearch Zone':
  Chunks:20, Allocs:37250, Used:5229720, Free:12040, Wasted:1120
Zone 'resultSort Zone':
  Chunks:0, Allocs:0, Used:0, Free:0, Wasted:0

Memory usage summary: After Result Free

Alloc calls: 614, Realloc calls: 107, Free calls: 388
Requested: Maximum usage: 15105086, Current usage: 5997384
Estimated: Maximum usage: 15105628, Current usage: 5997916
Freed
2 Hits 125

Memory usage summary: After Query

Alloc calls: 729, Realloc calls: 108, Free calls: 453
Requested: Maximum usage: 15105086, Current usage: 11281298
Estimated: Maximum usage: 15105628, Current usage: 11281840
Zone 'resultSearch Zone':
  Chunks:20, Allocs:37250, Used:5229720, Free:12040, Wasted:1120
Zone 'resultSort Zone':
  Chunks:0, Allocs:0, Used:0, Free:0, Wasted:0

Memory usage summary: After Result Free

Alloc calls: 729, Realloc calls: 108, Free calls: 503
Requested: Maximum usage: 15105086, Current usage: 5997384
Estimated: Maximum usage: 15105628, Current usage: 5997916
Freed
3 Hits 125

Memory usage summary: After Query

Alloc calls: 844, Realloc calls: 109, Free calls: 568
Requested: Maximum usage: 15105086, Current usage: 11281298
Estimated: Maximum usage: 15105628, Current usage: 11281840
Zone 'resultSearch Zone':
  Chunks:20, Allocs:37250, Used:5229720, Free:12040, Wasted:1120
Zone 'resultSort Zone':
  Chunks:0, Allocs:0, Used:0, Free:0, Wasted:0

Memory usage summary: After Result Free

Alloc calls: 844, Realloc calls: 109, Free calls: 618
Requested: Maximum usage: 15105086, Current usage: 5997384
Estimated: Maximum usage: 15105628, Current usage: 5997916
Freed
4 Hits 125

Memory usage summary: After Query

Alloc calls: 959, Realloc calls: 110, Free calls: 683
Requested: Maximum usage: 15105086, Current usage: 11281298
Estimated: Maximum usage: 15105628, Current usage: 11281840
Zone 'resultSearch Zone':
  Chunks:20, Allocs:37250, Used:5229720, Free:12040, Wasted:1120
Zone 'resultSort Zone':
  Chunks:0, Allocs:0, Used:0, Free:0, Wasted:0

Memory usage summary: After Result Free

Alloc calls: 959, Realloc calls: 110, Free calls: 733
Requested: Maximum usage: 15105086, Current usage: 5997384
Estimated: Maximum usage: 15105628, Current usage: 5997916
Freed

Memory usage summary: After SwishClose

Alloc calls: 959, Realloc calls: 110, Free calls: 959
Requested: Maximum usage: 15105086, Current usage: 0
Estimated: Maximum usage: 15105628, Current usage: 0

Unfreed memory: After SwishClose

Total Unfreed size: 0
Received on Wed Jul 7 05:26:11 2004