comparison mercurial/revlog.py @ 41286:00b314c42094

revlog: document that mmap resources are released implicitly by GC It's okay-ish, but currently the open fd and the mapping itself are leaked until the indexdata is deallocated. If revlog had close(), the underlying resources should be closed there as well, but AFAIK there's no such hook point.
author Yuya Nishihara <yuya@tcha.org>
date Sun, 13 Jan 2019 14:56:26 +0900
parents 1421d0487a61
children 13c23396c7fe
comparison
equal deleted inserted replaced
41285:cf8677cd7286 41286:00b314c42094
438 self._initempty = True 438 self._initempty = True
439 try: 439 try:
440 with self._indexfp() as f: 440 with self._indexfp() as f:
441 if (mmapindexthreshold is not None and 441 if (mmapindexthreshold is not None and
442 self.opener.fstat(f).st_size >= mmapindexthreshold): 442 self.opener.fstat(f).st_size >= mmapindexthreshold):
443 # TODO: should .close() to release resources without
444 # relying on Python GC
443 indexdata = util.buffer(util.mmapread(f)) 445 indexdata = util.buffer(util.mmapread(f))
444 else: 446 else:
445 indexdata = f.read() 447 indexdata = f.read()
446 if len(indexdata) > 0: 448 if len(indexdata) > 0:
447 versionflags = versionformat_unpack(indexdata[:4])[0] 449 versionflags = versionformat_unpack(indexdata[:4])[0]