"Bad allocation" in OpenCV in VS2017 Debug Mode - c++

I'm currently working with C++/OpenCV using VS2017 and had no problems reading a video-stream from a file (using VideoCapture).
However, I am getting the following error message, when building in Debug Mode:
warning: Error opening file (/build/opencv/modules/videoio/src/cap_ffmpeg_impl.hpp:901)
warning: pΦ∩á╬ (/build/opencv/modules/videoio/src/cap_ffmpeg_impl.hpp:902)
[ERROR:0] VIDEOIO(cvCreateCapture_MSMF(filename)): raised C++ exception:
bad allocation
I am wondering where the error might be coming from, as the program works perfectly fine in Release Mode.
I might add, that the video files I am testing with are approx. 2.7 GB to 8.8 GB large.
Is this an allocator issue inside the VS2017-Debugger hitting the int32_max limit
of 2³¹ bit (even though it is a 64Bit-Process)?

Related

'Virtual range for PCH exceeded' issue - after Visual Studio 2019 Upgrade to 16.7.6

This might be related to 38479787/c3859-virtual-memory-range-for-pch-exceeded.
A good read on PCH issues and recommendations can be found here.
After we've upgraded from VS2019 16.6 to VS2019 16.7.6, we're sometimes getting the infamous C3859 error when compiling our MSVC solutions.
We're using x64 msbuild from the command line.
/maxcpucount for MSBuild is fixed to '4'
/MP is passed, we're compiling on 8-core i7 machines.
The exact same source occasionally fails to compile with the errors
Compiler Error C3859 "virtual memory range for PCH exceeded"
System Code 1455 "The paging file is too small for this operation to complete."
Fatal error C1076 "compiler limit : internal heap limit reached"s
sample compilation output:
1342>c1xx : error C3859: Fehler beim Erstellen des virtuellen Speichers für PCH. [C:\REDACTED\REDACTED.vcxproj]
c1xx : message : Das System hat den Code 1455 zurückgegeben: Die Auslagerungsdatei ist zu klein, um diesen Vorgang durchzuführen. [C:\REDACTED\REDACTED.vcxproj]
c1xx : message : Weitere Informationen finden Sie unter https://aka.ms/pch-help. [C:\REDACTED\REDACTED.vcxproj]
1342>c1xx : fatal error C1076: Compilerlimit: Interne Heapgrenze erreicht. [C:\REDACTED\REDACTED.vcxproj]
1342>c1xx : fatal error C1076: Compilerlimit: Interne Heapgrenze erreicht. [C:\REDACTED\REDACTED.vcxproj]
The generated PCHs are up to 300MB in size.
Passing the '/Zm' switch (with values up 1000) didn't make a difference.
We've had issues with this years ago, using VS2010 - back then setting '/Zm200' solved the problem for us (note the error codes back then explicitly told us to increase to '/Zm150' or higher).
'reducing the complexity and size of our PCH files' really is not what we want to do - as we're intentionally sacrificing on memory in order to speed up our builds.
I'm wondering if there is a way to figure out what the actual underlying problem is that generates these sporadic occuring errors - and most important: how to fix it .
Actually, it is quite a headache issue for a couple of years. And the workaround which you found is the current solution and does help build your project successfully before VS2019 16.7 version. And upgrading VS to 16.7, the issue still sometimes happens with all the workarounds you have used. This does have a certain relationship with the VS IDE version and your project. This is a problem caused by two aspects.
Since you don’t want to change the PCH file, I have reported the issue on our DC Forum.
You can vote it and add any comments if I did not describe the issue in detail so that it will get more Microsoft's attention.
=======================================
If you are using VS Professional or Enterprise version and willing to accept the risk of reinstalling the previous version of VS, you can try this. And if you do not want it, you can just ignore it.
Refer to this document and uninstall the current VS version and install the related 16.6 version from that link.
Besides, you could share a minimal, reproducible sample with us if you like.
I am using a virtual machine (VPS), and the final solution for me was to increase my virtual memory pagefile size. It may be that it was only efficient due to the NVMe SSD drive, but it may work well enough for whoever is reading this, regardless.
(Credit for this guide: [MSFT]Ulzii Luvsanbat)
Open the Control Panel
Select System and Security
Select System
In the Advanced tab of the System Properties dialog, select the Performance “Settings” button
Select the Virtual Memory “Change” button on the Advanced tab
Turn off “Automatically manage paging file size for all drives” and set the Custom size. Note that you should set both the “initial size” and “maximum size” to the same value, and you should set them to be large enough to avoid the OS exhausting the page file limit.

Synced code from windows 7 to windows 10. Now have errors with line endings

I was working on a project last night in windows 7, i finished so used github-visual studio extension to sync with my repository. Pulled it up on my windows 10 machine this morning and all of a sudden i am getting a message saying that the file endings are inconsistent, so i tried both leaving them and changing them. No matter what i am doing i am getting this error:
Exception thrown at 0x75AD2CD2 in BreakoutDebug.exe: Microsoft C++ >exception: tle::CTLException at memory location 0x012FF5DC.
I have tried re-cloning the repository to see if that made any difference, but to no avail and also tried using the vs feature where it sorts out line ending inconsistencies for you
This is the line that is showing the error:
while (engine->IsRunning())
{
engine->DrawScene();
//All code to move sprites goes here
}
It was that the framework i was using was vs2015 version and relied on old dependancies, updatedto 2017 version of framework and it works fine

Dr Memory will not run with SDL ttf (2.0.10)

Upon adding SDL_ttf (2.0.10), DrMemory refuses to work anymore. The console went from printing out the messages to outputting nothing and sending the following to stdout:
~~Dr.M~~ WARNING: unable to locate results file: can't open D:\DrMemory
\drmemory\logs/resfile.6188 (code=2). Dr. Memory failed to start the
target application, perhaps due to interference from invasive security
software. Try disabling other software or running in a virtual machine.
Is there any way around this with some command line flag for Dr Memory or will I have to forego using Dr Memory?
Note: It works perfectly fine with other SDL stuff until I add the TTF Library and add a TTF_Font *font somewhere. The code I have works fine and there is no loading errors or anything wrong with it, it's at a very primitive level and fresh/new. I just cannot get Dr Memory to work as soon as any TTF element is added to the source code.
It works with a 32-bit build, but not a 64-bit build... so I switched to using 32-bits.
Since this is not a full answer as to why. However if anyone finds it breaking for them, try 32-bit.

Compiling code too quickly gives errors

I have recently started coding with C++ and I have come across a little source of error which I think requires knowledge about computers that I don't have.
When I write a simple code (in Visual Studio Express 2013), let's say a "Hello World!" example, I Build and Start Without Debugging successfuly.
Then, when I edit my code to print the sum of two numbers for example, I get an error when I try to Build. I get this error:
Error 1 error LNK1168: cannot open c:\users\name\documents\visual
studio 2013\Projects\ConsoleApplication4\Debug\ConsoleApplication4.exe
for writing
But if I wait for a bit and then re-attempt to Build, everything is fine.
I have also noticed this when I use g++ in the standard cmd module; if I try to complile a code under the same name (for the .exe file) I get an Access Denied error, but if I wait a bit I am allowed to do it.
My instincts tell me that the computer still has the .exe file running for a bit after I execute it, and it is not allowing me to overwrite it.
It's because the process is still running and therefore the file is in use and write-locked. It takes Windows a few tempo beats to clean everything up after you've terminated.

GLUT: Fatal Error: out of memory

I have an opengl implementation that runs fine on my desktop.
But even though i have it set up the exact same way on my laptop i get an "out of memory" error when i try to run it.
it is strange because on my desktop the application only takes up 200mb ram and i have 2gb available on the laptop
any ideas what might cause this?
btw im running the application through Visual Studio 2012 Ultimate and using the glut setup suggested in the first answer of this post: How to fix this Error: #include <gl/glut.h> "Cannot open source file gl/glut.h"
Check the encoding of your file
(http://lists.apple.com/archives/mac-opengl/2006/Jun/msg00070.html)
Ensure you're using the same runtime environment
(have you installed the same glut.dll on your laptop?)
Finally, I have a question:
What do you mean "running the application through Visual Studio"? Do you hit Ctrl+F5?
I found the solution, it is rather dumb.
I had set up "main" as "Entry Point" in "Project Preferences -> Linker -> Advanced" because it was necessary on my desktop.
I removed this so i had a blank "Entry Point" and my code runs fine ^^
posting in case someone needs this info