Array size in Visual C++ -
Array size in Visual C++ -
using visual studio 2012, if type following:
char bytes[ 2*1024*1024*1024 ];
i error: "matrix size must greater zero". same occurs if declare size dynamically, i.e.:
char* bytes = new char[ 2*1024*1024*1024 ];
if remove first "2", fine. seems there's hard limit on amount of memory can request either stack or heap, beingness limit 1 gb. however, given size_t 4 bytes in worst case (it 8 bytes sure), there not problem in index not beingness able address space of array. problem limit imposed stack , heap 1mb default? (http://msdn.microsoft.com/en-us/library/f90ybzkh(v=vs.110).aspx). if case, why can allocate 1 gb?
you need take care not overflow 32 bit int look - 2*1024*1024*1024
2^31
, 1 larger int_max
. try:
char bytes[ 2ull*1024*1024*1024 ];
note compile error has nil stack or heap size. whether can allocate amount of memory separate problem.
c++ visual-c++
Comments
Post a Comment