flat assembler
Message board for the users of flat assembler.

Index > Windows > # of VirtualAlloc calls per process?..

Author
Thread Post new topic Reply to topic
AsmGuru62



Joined: 28 Jan 2004
Posts: 1657
Location: Toronto, Canada
AsmGuru62 26 Jul 2013, 23:13
Hi everyone,

Does anyone know if there is a limit of VirtualAlloc calls per process?
Win32 Platform.
Post 26 Jul 2013, 23:13
View user's profile Send private message Send e-mail Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20416
Location: In your JS exploiting you and your system
revolution 26 Jul 2013, 23:26
AsmGuru62 wrote:
Does anyone know if there is a limit of VirtualAlloc calls per process?
Win32 Platform.
After 2^31/2^12 calls you will have no virtual memory space left to allocate.
Post 26 Jul 2013, 23:26
View user's profile Send private message Visit poster's website Reply with quote
Alphonso



Joined: 16 Jan 2007
Posts: 295
Alphonso 27 Jul 2013, 03:22
Unless using 4GT tuning, what is it that are you trying to do AsmGuru62?
Post 27 Jul 2013, 03:22
View user's profile Send private message Reply with quote
AsmGuru62



Joined: 28 Jan 2004
Posts: 1657
Location: Toronto, Canada
AsmGuru62 27 Jul 2013, 20:18
I am writing a heap replacement code with some diagnostics.
Post 27 Jul 2013, 20:18
View user's profile Send private message Send e-mail Reply with quote
blacky



Joined: 06 Apr 2006
Posts: 32
Location: JA
blacky 28 Jul 2013, 14:52
I think there is also one detail to that question, and thats if you're allocating the memory and commiting it. See this blog post for an in depth analysis on Virtual Memory on Windows:
http://blogs.technet.com/b/markrussinovich/archive/2008/11/17/3155406.aspx?Redirected=true
Post 28 Jul 2013, 14:52
View user's profile Send private message MSN Messenger Reply with quote
AsmGuru62



Joined: 28 Jan 2004
Posts: 1657
Location: Toronto, Canada
AsmGuru62 28 Jul 2013, 21:37
Thanks!
The memory segments for my heap will be allocated with both flags:
Code:
invoke VirtualAlloc, 0, 10000h, MEM_RESERVE or MEM_COMMIT, PAGE_READWRITE    
Post 28 Jul 2013, 21:37
View user's profile Send private message Send e-mail Reply with quote
comrade



Joined: 16 Jun 2003
Posts: 1150
Location: Russian Federation
comrade 01 Aug 2013, 09:04
revolution wrote:
AsmGuru62 wrote:
Does anyone know if there is a limit of VirtualAlloc calls per process?
Win32 Platform.
After 2^31/2^12 calls you will have no virtual memory space left to allocate.


It's actually much less than that since the allocation granularity is typically 64 KB, not 4 KB. Look at SYSTEM_INFO.dwAllocationGranularity. That is, if you do:


  1. VirtualAlloc 1 byte
  2. VirtualAlloc 1 byte


You will consume 128 KB of VA, not 8 KB.

And of course the 2^31 member is also variable: if you run with /3GB and your EXE links with IMAGELARGEADDRESSAWARE, then you will have 3GB of usable user-mode VA on a 32-bit native OS, and the full 4 GB of VA on a 64-bit native OS.

Relevant references:
http://msdn.microsoft.com/en-us/library/windows/desktop/bb613473%28v=vs.85%29.aspx
http://msdn.microsoft.com/en-us/library/windows/desktop/ms724958%28v=vs.85%29.aspx
http://msdn.microsoft.com/en-us/library/windows/desktop/aa366887%28v=vs.85%29.aspx

_________________
comrade (comrade64@live.com; http://comrade.ownz.com/)
Post 01 Aug 2013, 09:04
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
AsmGuru62



Joined: 28 Jan 2004
Posts: 1657
Location: Toronto, Canada
AsmGuru62 01 Aug 2013, 13:44
Great! Thanks for the answer!
I will be allocating at least by 64Kb chunks.
Post 01 Aug 2013, 13:44
View user's profile Send private message Send e-mail Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.