flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > Memory problem

Author
Thread Post new topic Reply to topic
President



Joined: 26 Jun 2003
Posts: 9
Location: Estonia
President
When trying to compile, Fasm shows an error message: out of memory. This didn't happen with previous versions of Fasm though.
I know my PC has very little RAM (only 48 MB) but why Fasm doesn't want to use any virtual memory (on HDD)? It should be possible to use Fasm even when there is no free RAM available. Currently it is possible to compile with ANY other assembler, but not with Fasm.
The memory handling should be improved.

President.
Post 26 Jun 2003, 23:34
View user's profile Send private message MSN Messenger Reply with quote
President



Joined: 26 Jun 2003
Posts: 9
Location: Estonia
President
Oh, I forgot to mention that I use the console version of Fasm for DOS/Win32.
Post 26 Jun 2003, 23:39
View user's profile Send private message MSN Messenger Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7734
Location: Kraków, Poland
Tomasz Grysztar
I had to change it a little bit in the latest version of fasm, because I've got some complaints about unwanted swap file increase with the previous releases. The main problem that causes it all is that fasm needs the whole block of memory it will use to be allocated before starting the compilation (this is the architectural relict, caused by the fasm's origin - it was originally written for single-task OS without any virtual memory). Currently fasm allocates 50% of physical memory, but it was a mistake, it had to be 75%. Look in the SOURCE/WIN32/SYSTEM.INC file, there is an init_memory routine. In 1.46.9.6 it begins with:
Code:
        push    buffer
        call    [GlobalMemoryStatus]
        mov     eax,dword [buffer+12]
        mov     edx,eax
        shr     edx,1
        sub     eax,edx    

Replace shr edx,1 with shr edx,2 to fix my mistake. If you want, you can also replace mov eax,dword [buffer+12] with mov eax,dword [buffer+28] to use the whole virtual memory size intead of physical memory size as a base for calculation, but I won't do it in the official releases.
It is also possible to make Win32 version of fasm handle out_of_memory error differently - it may increase the memory block an begin compilation once again instead of displaying an error message and exiting, what do you think?
Post 27 Jun 2003, 09:06
View user's profile Send private message Visit poster's website Reply with quote
President



Joined: 26 Jun 2003
Posts: 9
Location: Estonia
President
I replaced "shr edx,1" with "shr edx,2" and compiled the Win32 console Fasm with Win32 GUI Fasm. Then I tried to compile something with the modified version of Fasm, but it is still problematic: sometimes it compiles, sometimes exits with the out_of_memory error.
By the way, the GUI version works all the time perfectly. Maybe because there I can set the amount of memory to allocate for compiling. Now maybe adding a command line option to set the memory block size manually (for the console Fasm) could help to correct problems?

President.
Post 27 Jun 2003, 16:39
View user's profile Send private message MSN Messenger Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7734
Location: Kraków, Poland
Tomasz Grysztar
It seems you have very small amount of free physical memory - please try the further modification.
Anyway I can also make the console fasm use the .ini file to read the memory settings and environment variables like the GUI version...
Post 27 Jun 2003, 17:58
View user's profile Send private message Visit poster's website Reply with quote
President



Joined: 26 Jun 2003
Posts: 9
Location: Estonia
President
Oh, yes! Reading .INI file would be fine!

President.
Post 27 Jun 2003, 21:34
View user's profile Send private message MSN Messenger Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7734
Location: Kraków, Poland
Tomasz Grysztar
Please try the 1.47, I've changed it to use half of the existing physical memory - in your case it should be 24 MB, and it shouldn't touch the swap too much I hope.
Post 27 Jun 2003, 21:39
View user's profile Send private message Visit poster's website Reply with quote
President



Joined: 26 Jun 2003
Posts: 9
Location: Estonia
President
Yes, thanks, Privalov! Now it works!
But, you could still make something to enable to set the size manually too. For example, half is the default, but even if it is not enough (or is too much), then it should be possible to set an optional command line option for this. For example, to compile app.asm to app.exe and allocate only 4 MB of memory, I could execute Fasm as follows:

fasm.exe app.asm app.exe 4096

What do you think? But even if you don't agree, I am still happy with the current working variant.
Post 27 Jun 2003, 23:20
View user's profile Send private message MSN Messenger Reply with quote
scientica
Retired moderator


Joined: 16 Jun 2003
Posts: 689
Location: Linköping, Sweden
scientica
President wrote:
fasm.exe app.asm app.exe 4096

It would be more siutable with:
Code:
fasm -a 4096 app.asm app.exe    

-a for allocate (possibly --allocate for linux versions)
it's better with a switch so one don't need to specify it every time, or we might end up with compile lines like:
Code:
fasm app.asm app.exe 4096 PE GUI 4.0 on stub.foo use32 consider this and that and even more args    
Wink

_________________
... a professor saying: "use this proprietary software to learn computer science" is the same as English professor handing you a copy of Shakespeare and saying: "use this book to learn Shakespeare without opening the book itself.
- Bradley Kuhn
Post 28 Jun 2003, 19:26
View user's profile Send private message Visit poster's website Reply with quote
President



Joined: 26 Jun 2003
Posts: 9
Location: Estonia
President
I would fully agree with:
Code:
fasm -a 4096 app.asm app.exe    

The question is... will Privalov agree with it.

But, scientica, there will never be such command lines anyway like:
Code:
fasm app.asm app.exe 4096 PE GUI 4.0 on stub.foo use32    

The other arguments are placed inside the source. Only the memory allocation argument (beside the source.asm and output.exe) would be in the command line.
Post 28 Jun 2003, 22:07
View user's profile Send private message MSN Messenger Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7734
Location: Kraków, Poland
Tomasz Grysztar
Yes, I think it would be good to implement such switch (I'd prefer to use -m 4096 form), also for the Linux version.
Post 28 Jun 2003, 22:18
View user's profile Send private message Visit poster's website Reply with quote
President



Joined: 26 Jun 2003
Posts: 9
Location: Estonia
President
Yes, it would be great!

Thanks Privalov! Cool
Post 29 Jun 2003, 10:18
View user's profile Send private message MSN Messenger Reply with quote
scientica
Retired moderator


Joined: 16 Jun 2003
Posts: 689
Location: Linköping, Sweden
scientica
privalov wrote:
Yes, I think it would be good to implement such switch (I'd prefer to use -m 4096 form), also for the Linux version.

You see the problem lies in the fact that in my customization of fasmw (named Phantome) the -m switch is used for make (and -r for fun). Rolling Eyes
So to me -a (as in allocate (memnory) is more siutable).

But you are the master and author of fasm, if you want that switch to be -m then I'll have to find some other "switch name". I bow before thee for thou are root. Wink

_________________
... a professor saying: "use this proprietary software to learn computer science" is the same as English professor handing you a copy of Shakespeare and saying: "use this book to learn Shakespeare without opening the book itself.
- Bradley Kuhn
Post 29 Jun 2003, 11:37
View user's profile Send private message Visit poster's website Reply with quote
Dryobates



Joined: 13 Jul 2003
Posts: 46
Location: Poland
Dryobates
Is that feature is enabled in Linux version? I don't see it Sad
I run compiler end it tells me that there's now free memory. I've got 300MB free memory (640MB total). If Linux version uses half of memory then it's too much for my purposes. It is a little difficult to recompile fasm sources with other values since there's almost always half of the memory is used.

Is that line switching feature is forgotten?

(Fasm 1.51, FreeBSD 5.1).
Post 01 Mar 2004, 21:45
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger ICQ Number 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. Also on YouTube, Twitter.

Website powered by rwasa.