2014-11-09 22:38 GMT+08:00 Michael Van Canneyt <mich...@freepascal.org>:
> Code like this: > > ci := PCacheItem((buf + SizeOf(Pointer) * Random(FDepth))^); > for i := 0 to FDepth - 1 do begin > slot := buf + SizeOf(Pointer) * i; > if Pointer(slot^) = nil then begin > Inc(N); > Pointer(slot^) := GetMem(SizeOf(TCacheItem)); > ci := PCacheItem(slot^); > > makes me frown, because the first assignment to ci is useless, so highly > suspect. You are right Michael. I just found that if there is no free slot, I use "Random Replacement" to dump one of the existing cached item, whose key is not freed, which caused memory leak. Thanks! Xiangrong.
_______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal