Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.
7956 Discussions

Long-term fix for "Unable to obtain mapped memory"

TZeit
Beginner
477 Views

Hello Intel Guys,

I repeatedly run into the "Unable to obtain mapped memory" issue for large PCH files with multiple of my project files on Windows. This usually happens when changing the Windows platform the compiler runs on, or using another computer, or upgrading the compiler version, or changes in a project related to PCH, ...

I am aware of the existing threads discussing this issue and I am also aware of the workaround to solve it (base address parameter). But this is a very annoying issue and I would prefer to get rid of it and not to waste time to fix it again and again.

Do you plan to finally fix this issue in the compiler itself? And if yes, when?

(Currently using 2017 Update 4)

0 Kudos
2 Replies
jimdempseyatthecove
Honored Contributor III
477 Views

Currently running Intel Parallel Studio 19.0u2

Earlier forum messages suggested looking at https://software.intel.com/en-us/articles/unable-to-obtain-mapped-memory

This requires the use of /Qoption,cpp,--pch_control=HexAddressYouFigureOut

Unfortunately, V19.0u2 icl does not include this option.

*** Note

I am compiling the project (MS VS 2013) on Windows 7 with "Not Using Precompiler Headers"

I notice that in my stdafx.h file I use:

...
#if 0
#include <Windows.h>
#include <conio.h>
#include <tchar.h>
#include <AtlBase.h>
#include <AtlConv.h>
#include <intrin.h>
#endif
...

That the program will build.

If I move the <Windows.h> line to the expanded section, I get the error.

This particular example code can live without Windows.h
*** however other programs must include Windows.h

This problem is a Show Stopper.

Jim Dempsey

0 Kudos
jimdempseyatthecove
Honored Contributor III
477 Views

Found a work around.

Apparently #include "stdafx.h" forces (enables) pch regardless of the option switch to disable precompiled headers.

If I code

#if 0
#include "stdafx.h"
#else
#if defined(__linux)

#else
// assume Windows
//#define _WIN32_WINNT 0x0502	// Change this to the appropriate value to target other versions of Windows.
//#define USE_profiler
#include "targetver.h"
#include <Windows.h>
#include <conio.h>
#include <tchar.h>
#include <AtlBase.h>
#include <AtlConv.h>
#include <intrin.h>
#endif

#include <stdio.h>
#include <ctype.h>
#include <iostream>
#include <fstream>
#include <chrono>
#include <float.h>
#include <math.h>
#endif

Where the above new expansion is the contents of stdafx.h the build works.

Jim Dempsey

0 Kudos
Reply