mirror of https://github.com/python/cpython
Issue #21116: Avoid blowing memory when allocating a multiprocessing shared
array that's larger than 50% of the available RAM. Patch by Médéric Boquien.
This commit is contained in:
parent
4269d6db93
commit
d5aec7ba48
|
@ -71,7 +71,14 @@ else:
|
||||||
os.unlink(name)
|
os.unlink(name)
|
||||||
util.Finalize(self, os.close, (self.fd,))
|
util.Finalize(self, os.close, (self.fd,))
|
||||||
with open(self.fd, 'wb', closefd=False) as f:
|
with open(self.fd, 'wb', closefd=False) as f:
|
||||||
f.write(b'\0'*size)
|
bs = 1024 * 1024
|
||||||
|
if size >= bs:
|
||||||
|
zeros = b'\0' * bs
|
||||||
|
for _ in range(size // bs):
|
||||||
|
f.write(zeros)
|
||||||
|
del zeros
|
||||||
|
f.write(b'\0' * (size % bs))
|
||||||
|
assert f.tell() == size
|
||||||
self.buffer = mmap.mmap(self.fd, self.size)
|
self.buffer = mmap.mmap(self.fd, self.size)
|
||||||
|
|
||||||
def reduce_arena(a):
|
def reduce_arena(a):
|
||||||
|
|
|
@ -154,6 +154,7 @@ Wouter Bolsterlee
|
||||||
Gawain Bolton
|
Gawain Bolton
|
||||||
Forest Bond
|
Forest Bond
|
||||||
Gregory Bond
|
Gregory Bond
|
||||||
|
Médéric Boquien
|
||||||
Matias Bordese
|
Matias Bordese
|
||||||
Jonas Borgström
|
Jonas Borgström
|
||||||
Jurjen Bos
|
Jurjen Bos
|
||||||
|
|
|
@ -29,6 +29,9 @@ Core and Builtins
|
||||||
Library
|
Library
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
- Issue #21116: Avoid blowing memory when allocating a multiprocessing shared
|
||||||
|
array that's larger than 50% of the available RAM. Patch by Médéric Boquien.
|
||||||
|
|
||||||
- Issue #22982: Improve BOM handling when seeking to multiple positions of
|
- Issue #22982: Improve BOM handling when seeking to multiple positions of
|
||||||
a writable text file.
|
a writable text file.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue