Skip to content

numpy.zeros((0, 2**31-1)) raises MemoryError #7819

Closed
@cgohlke

Description

@cgohlke

Using numpy-1.11.1 with the patch for issue #7813 on 64-bit Python, creating an array of size=0 several times raises MemoryError on a Windows 10 system with 32 GB RAM:

Python 2.7.12 (v2.7.12:d33e0cf91556, Jun 27 2016, 15:24:40) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>> a = numpy.zeros((0, 2**31-1))
>>> a.size
0
>>> a = numpy.zeros((0, 2**31-1))
>>> a = numpy.zeros((0, 2**31-1))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
MemoryError

According to the the VMMap tool, every call to numpy.zeros((0, 2**31-1)) allocates ~16GB on the heap.
I would not expect the creation of an array of size=0 to fail with MemoryError (64-bit) or ValueError (32-bit).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions