www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Help debugging an core.exception.OutOfMemoryError

reply Danny Arends <Danny.Arends gmail.com> writes:
Hey all,

When running a D program that i wrote (32bit mode, windows10), an 
OutOfMemory exception being thrown when executing the program:

core.exception.OutOfMemoryError src\core\exception.d(702): Memory 
allocation failed

However there is no stack trace being generated (due to the 
program being out of memory).

How do I figure out where in the user code the out of memory 
error is coming from/occurring ?

Thanks in advance,
Danny

ps. Using Linux 64bit, this error does not occur
Mar 22 2018
parent =?UTF-8?Q?Ali_=c3=87ehreli?= <acehreli yahoo.com> writes:
On 03/22/2018 02:45 AM, Danny Arends wrote:
 Hey all,
 
 When running a D program that i wrote (32bit mode, windows10), an 
 OutOfMemory exception being thrown when executing the program:
 
 core.exception.OutOfMemoryError src\core\exception.d(702): Memory 
 allocation failed
 
 However there is no stack trace being generated (due to the program 
 being out of memory).
 
 How do I figure out where in the user code the out of memory error is 
 coming from/occurring ?
 
 Thanks in advance,
 Danny
 
 ps. Using Linux 64bit, this error does not occur
I don't think you can point at any one place because it's probably really running out of memory. The fact that it's only in 32-bit suggests that you're allocating large amounts of memory (perhaps simply some arrays are getting larger) and that some values in unrelated parts of the code are mistaken to be pointers into that memory, making them "alive" in the eye of the GC. This is a common issue with imprecise GCs like the current one that D uses. (It's highly likely that D's GC will always be imprecise because D allows casting a pointer to an integral type. For that reason, the GC cannot be sure whether your integer value 0x12345678 is a pointer or not.) If that really is the reason, a common advice is moving to 64-bit, where the likelihood of false pointers is about 4 billion times less than happening in 32-bit. (If my math is correct. :) ) Ali
Mar 22 2018