Author |
Topic: Open Letter to Chris Iverson (Read 732 times) |
|
Richard Russell
Administrator
member is offline
Posts: 1348
|
|
Open Letter to Chris Iverson
« Thread started on: Mar 31st, 2016, 10:02am » |
|
I have sent this to Chris Iverson in response to a post at the Liberty BASIC Community Forum:
Chris,
I was surprised to read in your response to John Hinckley that it has been "hard to track down" why exactly the 'unable to allocate virtual address space' error happens. Why it happens is straightforward: LB 4.5.0 attempts to allocate 1 Gbyte of *contiguous* virtual address space (which is half the total user address-space normally available to a Win32 program!) and that amount of contiguous address space is not guaranteed to be available.
As I expect you know, the reason that such a large amount of contiguous address space may not be available is that, before an application gets to run, several DLLs and other 'resident' modules first get loaded into memory. The effect of 'pre loading' those modules is that the address space gets 'fragmented'.
Imagine, for example, that a 1 Megabyte DLL happens to get loaded into memory 500 kBytes below the 1 Gbyte 'boundary'. Now the remaining user address space has been neatly divided into two equal parts, each of which is slightly under 1 Gbyte in size. Although only 1 Megabyte of memory has actually been used by the DLL, an attempt to allocate 1 Gbyte of contiguous address space is bound to fail.
That it sometimes happens and sometimes doesn't really isn't relevant. It will depend on what modules get pre-loaded and where, and that in turn will depend on what utilities and drivers are installed that 'inject' themselves into the address space of any running process (for example it is not uncommon for printer drivers to do that).
Any experienced Windows programmer should know that it isn't safe to allocate as much as 1 Gbyte of contiguous address space in a 32-bit program. If you are unlucky, just one resident module loaded at an 'unfortunate' address is enough to cause such an allocation to fail.
I make this information available in the spirit of cooperation, even though I know it is not reciprocated by the Liberty BASIC community. If it has been helpful I would appreciate an acknowledgement.
Regards,
Richard.
|
|
Logged
|
|
|
|
pierscintilla
New Member
member is offline
Gender:
Posts: 30
|
|
Re: Open Letter to Chris Iverson
« Reply #1 on: Mar 31st, 2016, 12:45pm » |
|
Clear and elegant!
Pier
|
|
Logged
|
|
|
|
Pensacola Pete
New Member
member is offline
Posts: 1
|
|
Re: Open Letter to Chris Iverson
« Reply #2 on: Jun 1st, 2016, 6:30pm » |
|
Thanks for the explanation. I use another program that is coded in Liberty Basic 4.5. I got the same "unable to allocate virtual address space" message. Previous versions coded in 4.04 didn't have this problem. Thanks to your explanation, I eventually was able to do a workaround by temporarily turning off Bitdefender's active threat scan, which allowed the program to load, then turning back on active threat scan. No idea if this is because what I turned off was occupying a crucial address area.
|
|
Logged
|
|
|
|
Richard Russell
Administrator
member is offline
Posts: 1348
|
|
Re: Open Letter to Chris Iverson
« Reply #3 on: Jun 1st, 2016, 7:10pm » |
|
on Jun 1st, 2016, 6:30pm, Pensacola Pete wrote:I eventually was able to do a workaround by temporarily turning off Bitdefender's active threat scan, which allowed the program to load |
|
I suppose I should ask why LBB didn't provide a solution in this case. LBB reserves half a Gbyte of contiguous address space by default, which is almost always available, but you can reduce that if necessary by editing the LBB.INI file.
Richard.
|
|
Logged
|
|
|
|
|