V8 grows virtual memory and then generates fatal error - v8

I'm calling following code after running each script:
unsigned nCycleCount = 0;
while(!v8::V8::IdleNotification()) { ++nCycleCount; }
to force garbage collection.
As result virtual memory amount rapidly grows and the V8 just indicates fatal error, it cannot allocated more virtual memory.
What is the reason? Is there any fix or workaround? Does anyone know?
Build Platform: Win32/x86
Compiler: VS2005 + SP1 + ATL Security Pack + MFC Security pack

Related

Why am I getting OutOfMemory exceptions when I have plenty of memory?

I have a program (Fractal10) that executes a loop where the number of iterations depends on a parameter I set manually. When the number of iterations is small the program runs fine. When the number of iterations is large I get the following error:
Unhandled Exception: System.TypeInitializationException: The type initializer for '<StartupCode$Fractal10>.$Program' threw an exception. ---> System.AggregateException: One or more errors occurred. ---> System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
I am running Windows 10 Professional with 16 GB of memory and 25600 MB of virtual memory on an Intel Haswell processor and the latest version of Microsoft Visual Studio 2017. After the exception is thrown, the Task Manager shows the following:
Memory: 64%
Fractal10 (32 bit)L 1,719.2 MB # this is the culprit
Microsoft Visual Studio 2017 (32 bit): 822.7 MB
... # other apps
Why am I getting this error when only 64% of memory has been used? Is there anything I can do about it?
You should use 64 bit versions of your software if you intend to use more than ~1,8 GB of memory.
First of all, is your OS 32 or 64bit? If it's the former, you won't actually have access to all of the installed memory.
Additionally, (and I'm assuming you're using the .Net framework, correct me if I'm wrong) you'll need to set your platform target to x64 inside your build configuration. On top of this, you can add the following config to your app.config file:
<runtime>
<gcAllowVeryLargeObjects enabled="true" />
</runtime>
This will allow traversal of objects greater than 2GB.

Visual Studio Express: fatal error c1060, the compiler is out of heap space

I'm trying to build a program from its source code with VC 11. When the compiler is about to finish, it raises the error mentioned in title of this post.
As I've read here and in other forums, I tried to both close as many programs as possible and enlarge the size of the swap file in Windows... neither works.
I've read about a parameter called \Zm but I don't understand how to use it.
Can you please help me?
Take a look at this documentation which gives possible solutions:
I also had that problem and found the documentation useful. Main points:
If the compiler also issues errors C1076 and C3859, use the /Zm compiler option to lower the memory allocation limit. More heap space
is available to your application if you lower the remaining memory
allocation.
If the /Zm option is already set, try removing it. Heap space might be
exhausted because the memory allocation limit specified in the option
is too high. The compiler uses a default limit if you remove the /Zm
option.
If you are compiling on a 64-bit platform, use the 64-bit compiler toolset. For information, see How to: Enable a 64-Bit Visual C++
Toolset on the Command Line.
On 32-bit Windows, try using the /3GB boot.ini switch.
Increase the size of the Windows swap-file.
Close other running programs.
Eliminate unnecessary include files.
Eliminate unnecessary global variables, for example, by allocating memory dynamically instead of declaring a large array.
Eliminate unused declarations.
Split the current file into smaller files.
I can't tell much about the /Zm parameter, but I had the same issue (compiler is out of heap space).
What has helped me was the /m:4 (4 for the count of your CPUs) parameter so that you can use multiple CPUs for building.
Hope that helps you as well.
Also, if you are running on x64, be sure that the x64 version of "msbuild.exe" and "cl.exe" is beeing used. I had the issue that even when using e.g. the x64 ms powershell, the compiler would still choose the 32-bit version of msbuild.exe (in task manager "msbuild.exe*32", windows 7)
In addition to the other answers here (and in my case), fatal error C1060: compiler is out of heap space can be caused by a syntax error. The following code (in certain circumstances) can cause this error even with correct compiler options -- for instance if you've previously successfully compiled the same program.
r.push_back(e[1];
instead of
r.push_back(e[1]);
It seems to only cause this error rather than the standard error C2143: syntax error: missing ')' before ';' when r and e are of certain types, but it's worth checking any code you've edited recently if the program previously compiled without errors.
We had similar problem: a relativelly simple program (although, full of templates, using Eigen library) persistently failed to compile on one of the computers. All were using MSVC2013 x64, but only one was unable to compile the program due to C1060 error. We tried different compiler flags, setting/unsetting -Zm, but failed to resolve it without modifying code.
Some pointers were, however, given to us, when we switched from x64/x64 (64bit compiler for 64bit resulting executable) version of the compiler to the x86/x86 (32bit compiler for 32bit resulting executable). The x86 compiler gave us exact locations of the problematic parts of the program - calls to template functions receiving heavy templated objects. We have rewritten those to normal functions (build in different object file) and that solved the problem...
VS: Visual Studio 2015
OS: Windows10
If you are using VS2015 as your IDE, maybe there is another solution:
Go to update the VS2015 "Update3" package and everything will work smoothly.
In my case, a main program would not compile is VS 2022 Community Edition (free). It had many include files. By process of elimination, I managed to compile it once I removed any "volatile" modifiers in declarations that had this modifier.
A very strange bug, to say the least!
I got this error when compiling OnnxRuntime with MS Visual C++ 17 2022.
The solution for this issue was to close all other programs and compile using a single thread (in this case, removing the --parallel argument from the build.bat call).

Shared memory between mingw and visual studio application

Is it possible to share a memory region between an application compiled with MinGW and one with Visual Studio ?
I am relying on boost interprocess:
shared_memory_object shm (create_only, "MySharedMemory", read_write);
shm.truncate(1000);
mapped_region region(shm, read_write);
int *pi = (int *)region.get_address();
I already realized that this is not possible via Cygwin, as the boost shared_memory_object is then created via the Cygwin posix layer.
A simple test program confirms that it is possible. One caveat is to use the exact same boost versions. Between boost 1.53 and 1.54 the unique id creation for the underlying memory mapped file has apparently changed.
I did however not check for memory alignment issues.

Win32 Error 8 during ccppc compile on Windows 7 x86

I'm trying to compile a number of C source files with ccppc (version 3.3-e500). Most of the time, the compilations will fail, noting the following error
0 [main] cc1 {PID} sigproc_init: cannot create wait_sig thread, Win32 Error 8
I've looked up this Win32 error, and it corresponds to ERROR_NOT_ENOUGH_MEMORY. I'm quite certain that it's not an issue with physical memory, I have 4GB in this machine, with no more than 1.5GB in use at compile time. Unfortunately, I don't have local admin over my machine, and therefore cannot investigate issues with the pagefile.
After several failures, the source will eventually compile, and once all the source is compiled, there are no apparent issues with the outputted .o's. However, this issue turns a 10-minute build into an hour+ build.
This issue is not present on XP x86 machines, I have not investigated x64 for either OS.
Has anyone run into an issue like this with ccppc or other gcc binaries on Windows 7? Any guidance in finding a solution would be awesome.
On moving from compiling under Windows XP 32-bit to Windows 7 64-bit, found that the cc1.exe program from gcc 2.96 for PowerPC was failing with the same error on some compiles. The investigation, using the Visual Studio Debugger to attach to cc1.exe and monitoring with Sysinternals tools, showed that:
When the cc1.exe program was successful it spawns 3 threads.
When the cc1.exe program failed, the 3rd CreateThread() call failed with ERROR_NOT_ENOUGH_MEMORY.
The image header of cc1.exe, as reported by running the Visual Studio dumpbin /HEADERS command, showed that the stack reserve size is 400000000 bytes. i.e. each thread created requires 400000000 bytes of contiguous virtual address space.
When the CreateThread call failed with ERROR_NOT_ENOUGH_MEMORY, the Sysinternals VMMap tool showed that the maximum free virtual memory region was less than the requested stack reserve size of 400000000 bytes.
cc1.exe is a 32-bit process, which has 2Gbytes of virtual address space. Windows 7 has ASLR (Address space layout randomization), which causes the load address of DLLs to be randomized. I think that the ASLR is effectively fragmenting the virtual address spaces, such that on some invocations of the cc1.exe process the virtual addresses used by the loaded DLLs doesn't leave a large enough free region for the thread stacks. As well as the ASLR, in Windows 7 there was approx 4 times more DLLs loaded into the cc1.exe compared to under Windows XP which could be contributing to the problem.
Based upon the above investigation, the Visual Studio editbin /STACK:67108864 program was used to reduce the stack reserve size for cc1.exe to 64Mbytes, where 64Mbytes was chosen as that was the stack reserve size for the cc1plus.exe program used for C++ code. With the reduction of the stack reserve size the ERROR_NOT_ENOUGH_MEMORY errors have not been seen again.
So, I never really found a solution, but I did manage to come up with a viable workaround.
Since the compile will eventually work after multiple re-make's, you can wrap your make command in a do/while loop that checks the 'ERRORLEVEL' variable, and continues until it indicates success.
This obviously doesn't solve the "takes forever to compile" problem, but your compile will eventually succeed.

Memory Error in Visual Studio, but plenty of memory available

This line of code produces the following error
rs[se_idx][ev_idx][re_idx].trs = new re_class[report_size];
std::bad_alloc at memory location 0x0037c29c
I think this is related to 'not enough memory'. When I decrease the amount being allocated, it runs fine.
I have plenty of memory (16 GB) on the machine and a resource monitor shows only a tiny fraction of it is being used by visual studio. I added the compiler options /F 4000000000 and /LARGEADDRESSAWARE, but still getting the error.
How can this be solved?
Are you sure your operating system can take advantage of the entire 16GB
and you're using a 64 bit version of VC++
http://msdn.microsoft.com/en-us/library/h2k70f3s%28v=vs.90%29.aspx
http://msdn.microsoft.com/en-us/library/9yb4317s%28v=vs.90%29.aspx

Resources