Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

memory alloc fails, tho there should be more than enough

28 views
Skip to first unread message

Heck

unread,
Jan 10, 2012, 12:52:46 PM1/10/12
to
Windows 7, 64 bit. 12 GB of memory (Control Panel\System and
Security\System confirms it).

My interest is in MapViewOfFile on a CreateFileMapping using a file
size of 1.5 GB. The call of MapViewOfFile fails due to out of memory
(system error 8). Just to be sure, I tried a calloc using the same
1.5 GB, which failed likewise.

Shouldn't there be more than enough in the virtual memory of the
process for this allocation? What might be amiss? What should I do
to proceeed?

TIA

Jeroen Mostert

unread,
Jan 10, 2012, 1:29:22 PM1/10/12
to
On 2012-01-10 18:52, Heck wrote:
> Windows 7, 64 bit. 12 GB of memory (Control Panel\System and
> Security\System confirms it).
>
> My interest is in MapViewOfFile on a CreateFileMapping using a file
> size of 1.5 GB. The call of MapViewOfFile fails due to out of memory
> (system error 8). Just to be sure, I tried a calloc using the same
> 1.5 GB, which failed likewise.
>
Is the process 64-bit? It's hard for a 32-bit process to get 1.5 GB of
contiguous free address space (which is what MapViewOfFile requires), since
there's only 2 GB of address space without large address awareness and still
only 4 GB with.

--
J.

Heck

unread,
Jan 10, 2012, 3:12:43 PM1/10/12
to
Thank you, that was my oversight. I had neglected to create a 64 bit
project.

I just presumed I was working with a 64 bit project since I was using
a 64 bit system. This is the first time I've had such large files to
manipulate.

Thanks very much/

Heck

unread,
Jan 10, 2012, 3:50:43 PM1/10/12
to
Well, I exulted too soon.

Now, within a 64 bit app, the calloc of 1.5 GB works, but not the
MapViewOfFile for a view of the same size. It fails with out of
memory, as before.

I've moved into the VS debugger to watch MapViewOfFile fail, but, when
running under the debugger, it doesn't fail.

Your suggestions, please.


On Tue, 10 Jan 2012 19:29:22 +0100, Jeroen Mostert
<jmos...@xs4all.nl> wrote:

Jeroen Mostert

unread,
Jan 10, 2012, 4:40:47 PM1/10/12
to
On 2012-01-10 21:50, Heck wrote:
> Now, within a 64 bit app, the calloc of 1.5 GB works, but not the
> MapViewOfFile for a view of the same size. It fails with out of
> memory, as before.
>
> I've moved into the VS debugger to watch MapViewOfFile fail, but, when
> running under the debugger, it doesn't fail.
>
Two ideas come to mind: either the failing executable is not, in fact, the
executable you just built and ran under the debugger (but an old copy of the
32-bit one, for example) or your code contains a bug that happens to not
manifest itself when running under the debugger.

MapViewOfFile() itself behaving differently when running under a debugger is
not impossible but vastly less likely.

--
J.
0 new messages