Question "VirtualAlloc (at place 2) returned NULL!"

Eamonn100

Reputable
Oct 23, 2020
352
11
4,695
Hi,

I'm having a problem with a game I play. After a certain amount of time, I get crash and a pop-up warning "VirtualAlloc (at place 2) returned NULL!"

I've found someone's solution to it but it's not 100% clear (to me at least) ... and before changing anything more, I would like to know what folks in the "know" think of it and perhaps get directed to making the correct changes, because what I changed so far hasn't worked.

At the very bottom I've attached the link/screenshot of the part of my computer I am in.


Below here in Bold and Italics is the person's solution to the problem, taken from another site.

"I had the same problem: "" VirtualAlloc (at place 2) returned NULL! "

It wasn't easy, it really took me an afternoon but I discovered the meaning and how to fix it. I am using Google Translate, I hope it is understood. I bother to sign up to help whoever has this same error:

- VirtualAlloc: refers to virtual memory, before windows 10 it was called a paging file.

- (at place 2): It refers to the problem is on a second hard drive, it would put (at place 1) if the problem was on drive C:

The solution is very simple, you must go to "PC settings", then "system", on the right of the window choose "about" and then on the left of the window choose "advanced system settings".

Well, in the open window called "system properties", go to the "advanced options" tab. In performance, click on the "configuration" button, choose the "advanced options" tab and in virtual memory click on the "change" button. So we finally get to the window where we can click for Windows 10 to automatically assign virtual memory to all drives, or manually assign to that second disk (in this case) the virtual memory that we want.


In my case, I assigned a fixed amount manually, but the simplest and most uncomplicated thing is to let Windows 10 do the job. I hope it is understood and that this helps others with the same problem."

View: https://imgur.com/M8x5UTB
 
that would be virtual memory aka paging file, increasing paging file size should help with this
but if that game has memory leak, than increasing paging file size isnt really solution

I don't know if the game has memory leak... but to do what the original posted solution suggests, what setting would you change?... or what settings would you suggest changing?
 
I don't know if the game has memory leak... but to do what the original posted solution suggests, what setting would you change?... or what settings would you suggest changing?
you dont need to have paging file on multiple drives, one is enough, try with 16GB
app in question which is crashing is probably 32bit app, those can use just 2GB ram and if they need more, they can get 2GB extra from ram if PAE is enabled, but anything above 2GB (+2PAE) gets swapped into virtual ram (pagging file)
 
you dont need to have paging file on multiple drives, one is enough, try with 16GB
app in question which is crashing is probably 32bit app, those can use just 2GB ram and if they need more, they can get 2GB extra from ram if PAE is enabled, but anything above 2GB (+2PAE) gets swapped into virtual ram (pagging file)

"you dont need to have paging file on multiple drives, one is enough, try with 16GB"... Where/what settings, on the screenshot I provided, would you change to do this?
 
I think this is referring to the c++ VirtualAlloc
and would more likely just be a coding bug.
ie allocation memory address being rounded down to address that is reserved.
this results in the api returning a NULL
you would have to see what address was being used.
adding more pagefile.sys space might fix the problem. (maybe)

good info in this thread:
Virtual alloc (at place two) returned null :: Total War: ROME II - Emperor Edition General Discussions (steamcommunity.com)

person in the above link reported the disk had filled up and limited the pagefile expansion. ie make sure there is free disk space and pagefile.sys is large enough.
 
Last edited:
I think this is referring to the c++ VirtualAlloc
and would more likely just be a coding bug.
ie allocation memory address being rounded down to address that is reserved.
this results in the api returning a NULL
you would have to see what address was being used.
adding more pagefile.sys space might fix the problem. (maybe)

good info in this thread:
Virtual alloc (at place two) returned null :: Total War: ROME II - Emperor Edition General Discussions (steamcommunity.com)

person in the above link reported the disk had filled up and limited the pagefile expansion. ie make sure there is free disk space and pagefile.sys is large enough.

Could you take a look at this. In it there's a syntax/"code". Is it a case of copy & pasting it into the black command prompt box and running it?

VirtualAlloc function (memoryapi.h) - Win32 apps | Microsoft Learn
 
nope, the person that has the code source would have to make the change and recompile and release the fix.
Are you saying that that syntax has to be entered into the games code files?

I only ask because this has been posted as a solution to the problem for anyone to do?

(Please forgive noob questions. I don't know much about these things).
 
Last edited:
Are you saying that that syntax has to be entered into the games code files?

I only ask because this has been posted as a solution to the problem for anyone to do?

(Please forgive noob questions. I don't know much about these things).
If the problem is the call via the programming language interface, then the coder would have to make the change and recompile the code.
if the problem is with the windows virtual memory then a end user might be able to change the windows virtual memory (pagefile.sys)
(two separate items)
game calls functions(virtualalloc) to access windows virtual memory (pagefile.sys).
the pagefile.sys can be too small or become corrupted. in this case you could: set a registry key to make windows delete the pagefile.sys on reboot and it will make another one. or you can tell windows to make a larger pagefile.sys.

How to delete the Windows 11 page file with every shutdown | TechRepublic
How To Manage Virtual Memory (Pagefile) In Windows 10 | Tom's Hardware (tomshardware.com)

if the problem is in the game code then only the developer would be able to make a fix.
 
If the problem is the call via the programming language interface, then the coder would have to make the change and recompile the code.
if the problem is with the windows virtual memory then a end user might be able to change the windows virtual memory (pagefile.sys)
(two separate items)
game calls functions(virtualalloc) to access windows virtual memory (pagefile.sys).
the pagefile.sys can be too small or become corrupted. in this case you could: set a registry key to make windows delete the pagefile.sys on reboot and it will make another one. or you can tell windows to make a larger pagefile.sys.

How to delete the Windows 11 page file with every shutdown | TechRepublic
How To Manage Virtual Memory (Pagefile) In Windows 10 | Tom's Hardware (tomshardware.com)

if the problem is in the game code then only the developer would be able to make a fix.
Would it be possible for you to take a look at my posted screen shot and suggest where and what values to change?

View: https://imgur.com/M8x5UTB