flat assembler
Message board for the users of flat assembler.

Index > Main > Out Of Memory

Author
Thread Post new topic Reply to topic
SPTH



Joined: 24 Jul 2004
Posts: 91
SPTH
Hey,
I have set at Compiler Setup -> Memory = 2.031.616.

Now I want to compile my program, and controlled it with the taskmanager.
Virtual Memory ~= 1GB, maximal Memory used = 795.208KB.

Then it crashes and says "Out of Memory".

So I guess FASM can use a maximum amount of 1GB, right?
Is there a way to change that? Something in the source that I could change?

Thanks!
Post 26 Apr 2011, 22:31
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
No, fasm is probably able to handle that much, but the problem is that there is not enough memory (or address space) to allocate that amount of memory, so fasm halves the size and tries to allocate again.

Check init_memory at \SOURCE\WIN32\SYSTEM.INC to see how it works.
Post 27 Apr 2011, 20:29
View user's profile Send private message Reply with quote
Madis731



Joined: 25 Sep 2003
Posts: 2141
Location: Estonia
Madis731
When your virtual memory is 1GB and you want FASM to allocate 2GB, it simply is not possible.
You need to have at least 3GB of virtual memory (because you have other programs running). Of course FASM cannot do what you request.
Post 28 Apr 2011, 09:38
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
SPTH



Joined: 24 Jul 2004
Posts: 91
SPTH
Thanks for your answeres. I have 3GB RAM here, afaik the OS uses 1.5GB. I have tested with VirtualAlloc, I can allocate 0x6000'0000 byte~1.6GB with a testprogram (without error, at 0x7000'0000 I get a ERROR_NOT_ENOUGH_MEMORY)

I wonder what is the problem for FASM.

Any further ideas?
Post 28 Apr 2011, 18:32
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
Because of the algorithm fasm uses for allocation, you'll have to probe several values until you see you are getting less memory than requested.

Having 3 GB of physical RAM, or physical RAM and page file combined is not enough to get more than 2 GB on a 32-bit system, you need the executable to be flagged with "large address aware" (FASMW is, but the console fasm version isn't right now), and also have the 3GB mode set.

Probing values to get the maximum shouldn't take you much time, just do a binary search starting from 1048576 KB. Once you get the maximum, better subtract a few megabytes to make sure it will always work.
Post 28 Apr 2011, 19:09
View user's profile Send private message Reply with quote
Madis731



Joined: 25 Sep 2003
Posts: 2141
Location: Estonia
Madis731
Under my Windows 7 (x64) with 4GB of RAM I get no errors from FASMW even if I try to compile with 16GB.

It gets interesting with console version though:
Code:
D:\Programs\FASM>FASM.EXE ..\QEMU\VESA64\Stage2\VESAKR64.asm -m 4000000
flat assembler  version 1.69.31  (1000000 kilobytes memory)
3 passes, 0.1 seconds, 8616 bytes.

D:\Programs\FASM>FASM.EXE ..\QEMU\VESA64\Stage2\FontV.asm -m 4000000
flat assembler  version 1.69.31  (1000000 kilobytes memory)
2 passes, 1868 bytes.

D:\Programs\FASM>FASM.EXE ..\QEMU\VESA64\VESA64.asm -m 4000000
flat assembler  version 1.69.31  (1000000 kilobytes memory)
1 passes, 1474560 bytes.

D:\Programs\FASM>FASM.EXE ..\QEMU\VESA64\VESA64.asm -m 8000000
flat assembler  version 1.69.31
usage: fasm <source> [output]
optional settings:
 -m <limit>    set the limit in kilobytes for the available memory
 -p <limit>    set the maximum allowed number of passes
 -s <file>     dump symbolic information for debugging

D:\Programs\FASM>
    


I don't know if to consider it a bug. I think it would be nice if FASM could tell you something logical like "you fool, there is no spoon! And there is not enough memory"

My binary search returned PHYSICALMEMORY-1 (in KB):
Code:
D:\Programs\FASM>FASM.EXE ..\QEMU\VESA64\VESA64.asm -m 4194304
flat assembler  version 1.69.31
usage: fasm <source> [output]
optional settings:
 -m <limit>    set the limit in kilobytes for the available memory
 -p <limit>    set the maximum allowed number of passes
 -s <file>     dump symbolic information for debugging

D:\Programs\FASM>FASM.EXE ..\QEMU\VESA64\VESA64.asm -m 4194303
flat assembler  version 1.69.31  (1048575 kilobytes memory)
1 passes, 1474560 bytes.
    
Post 29 Apr 2011, 16:53
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
Since I have a 2GB mode I started my searching at 2 GB:
Code:
C:\FASM>echo ; > input.asm

C:\FASM>fasm -m 2097152 input.asm
flat assembler  version 1.69.31  (1048576 kilobytes memory)
1 passes, 0 bytes.

C:\FASM>fasm -m 1572864 input.asm
flat assembler  version 1.69.31  (1572864 kilobytes memory)
1 passes, 0 bytes.

C:\FASM>fasm -m 1835008 input.asm
flat assembler  version 1.69.31  (1835008 kilobytes memory)
1 passes, 0 bytes.

C:\FASM>fasm -m 1966080 input.asm
flat assembler  version 1.69.31  (1966080 kilobytes memory)
1 passes, 0 bytes.

C:\FASM>fasm -m 2031616 input.asm
flat assembler  version 1.69.31  (2031616 kilobytes memory)
1 passes, 0 bytes.

C:\FASM>fasm -m 2064384 input.asm
flat assembler  version 1.69.31  (1032192 kilobytes memory)
1 passes, 0 bytes.    
The search is incomplete, since after the last step I should have attempted to test with the lower half value but I got bored.

I have only 1 GB of physical memory, so fasm can effectively allocate all the virtual memory provided that the free process' user address space can accommodate for the requested size.

Madis, perhaps if you recompile the console version by changing "format PE console" to "format PE large console" in \SOURCE\WIN32\FASM.ASM you'll be able to pull more memory. Note that your binary search didn't provide you the correct value, as you only allocated a little bit less than 1 GB.
Post 29 Apr 2011, 18:34
View user's profile Send private message Reply with quote
Madis731



Joined: 25 Sep 2003
Posts: 2141
Location: Estonia
Madis731
Now, as I understand, there are two levels of maximum memory. Anything above 4194303KB is more than 2^32 and therefore an error.
The second level is when too much is asked (between 0 and 2^32) then half of that is allocated. My maximum was 1890000KB, but it wasn't stable, other times I needed to go as low as 1870000KB to get it working again.
Standby (3039MB) + Free (184MB) was 3223MB at that time.

'large' didn't get me much further: 2096896KB (which was stable)
I think I'm dealing with 32-bit compatibility mode here where sys:apps are allocated 2GB:2GB. There are flags to change that behavior (like LocoDelAssembly linked), but actually I have never needed more than 8MB (8192KB selection in FASMW) for normal programs.

I know its relatively easy to find a synthetic (or a real-life) problem where FASM needs more than that, but its more of a principle thing than necessity.
Post 30 Apr 2011, 16:08
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger 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-2020, Tomasz Grysztar.

Powered by rwasa.