"Not enough memory", or a bad_alloc exception
as named in C++, can have many reasons:
- There is an error in code of the application (bug) - must be examined by a responsible software developer to fix it.
- RAM is heavily fragmented and therefore there is much available memory, but not much in a continuous block - reboot of machine helps.
- RAM is defect, a single bit failure (stuck 0 or stuck 1) causes abnormal code execution from time to time in various applications - executing the RAM test of the computer's manufacturer could be used to check that.
- Hard disk is defect and therefore the code of the application is not loaded into RAM as it was originally stored on hard disk - executing full hard disk check could be used to check that.
- An application is not written well and takes more and more GDI objects until limit of 65536 (default) is reached which is often not bad for already running applications, but for newly started applications - reboot of machine often helps and of course not using the application using more and more GDI objects.
- An application is not written well and takes more and more user objects which is usually a problem for the not well coded application only - restart of application often helps.
- An electromagnetic interference caused temporarily a memory corruption resulting in abnormal code execution. This reason is not possible to detect without special measurement equipment and can be detected at all only when abnormal code execution happens frequently caused by electromagnetic interferences.
- Others ...
The number of GDI and user objects used by a running process can be viewed on processes tab of Windows task manager or in Sysinternals Process Explorer after adding the appropriate columns.
Conclusion: Abnormal program execution is interesting for further examination only when it occurs several times within a certain period of time. The time period depends on device and importance of the application running on the device. A mobile phone for usage by people is completely different to a power plant control or protection device in regard to failures within a period of time.