flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > A question about '.bss" section

Author
Thread Post new topic Reply to topic
madmatt



Joined: 07 Oct 2003
Posts: 1045
Location: Michigan, USA
madmatt
What is the limit for memory allocation for a '.bss' section?
FasmW keeps giving me an out of memory error for value at or over 128MB.

here's an example:
Code:
section '.bss' data readable writeable
  memfilltest dd 65536*16*128 dup(?) ;allocate 128MB of memory    


fasmw halts for a few seconds then gives me an 'out of memory error', I checked my memory before compile, and have 1.56GB free.

_________________
Gimme a sledge hammer! I'LL FIX IT!
Post 11 Dec 2008, 18:17
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
But, do have you configured FASMW to use all that memory? The maximum default is 64 MB (which is not the default option neither if I remember right). Setting up a bigger memory size will do it.

BTW, your comment is wrong, you are allocating 512 MB of memory actually. Since you are using "dup (?)" I recommend you use "memfilltest rd 65536*4*128" instead since it is a lot faster.
Post 11 Dec 2008, 18:40
View user's profile Send private message Reply with quote
asmfan



Joined: 11 Aug 2006
Posts: 392
Location: Russian
asmfan
'.bss' data
"data" keyword means IMAGE_SCN_CNT_INITIALIZED_DATA (00000040h) flag for section but you need IMAGE_SCN_CNT_UNINITIALIZED_DATA (00000080h) flag thus omit "data" key cuz uninit is default flag for physical empty section. I consider this FASM behavior - setting silently 2 flags simultaneously - as bug.
Post 11 Dec 2008, 19:16
View user's profile Send private message Reply with quote
asmfan



Joined: 11 Aug 2006
Posts: 392
Location: Russian
asmfan
Also "dup" - is universal way between assemblers rather than some RB,RW,R* keywords.
Post 11 Dec 2008, 19:18
View user's profile Send private message Reply with quote
madmatt



Joined: 07 Oct 2003
Posts: 1045
Location: Michigan, USA
madmatt
LocoDelAssembly wrote:
But, do have you configured FASMW to use all that memory? The maximum default is 64 MB (which is not the default option neither if I remember right). Setting up a bigger memory size will do it.

BTW, your comment is wrong, you are allocating 512 MB of memory actually. Since you are using "dup (?)" I recommend you use "memfilltest rd 65536*4*128" instead since it is a lot faster.


To your first question, I've done a simple mod that allows me to set the maximum to 512mb, I'll soon add 1gb for testing purposes. To your second question, Yes, your right, I missquoted the figure, it should be 512MB. And to your final point, your right again, that method does go MUCH faster! Why would fasmw need so much memory for this operation?

asmfan wrote:
'.bss' data
"data" keyword means IMAGE_SCN_CNT_INITIALIZED_DATA (00000040h) flag for section but you need IMAGE_SCN_CNT_UNINITIALIZED_DATA (00000080h) flag thus omit "data" key cuz uninit is default flag for physical empty section. I consider this FASM behavior - setting silently 2 flags simultaneously - as bug.


I'll omit the 'data' keyword, still seems to work like it supposed too.

As you can tell, I don't have a complete understanding of how '.bss' sections work, maybe someone could enlighten me on this subject?

_________________
Gimme a sledge hammer! I'LL FIX IT!
Post 11 Dec 2008, 23:08
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
Quote:

To your first question, I've done a simple mod that allows me to set the maximum to 512mb, I'll soon add 1gb for testing purposes.

A mod? Why you couldn't made it with the official version? Note that the combo box only gives you some suggested values but you are free to type whatever number of KBs you want (with the obvious restrictions ofc but 1 GB is doable, just set memory to 1048576).

Quote:

Why would fasmw need so much memory for this operation?


Because FASM needs to have loaded on memory every memory region of the executable. You could tell here why FASM don't just make some "hole" to save RAM, but actually it is not that simple because some load/store after that declaration could affect that initially uninitialized memory (and this is only what comes to my mind, Tomasz could have devised some other factors, what I'm sure is that it was hardly due to Tomasz's lazyness Razz).

After setting 1048576 of memory (which was fully allocated and not recursively halved till success as might occur), this is the highest memory allocation I got:
Code:
format binary
rb 1024*1024*767    


I'm not very familiar with fasm internals but I think this limitation is caused because of the way fasm manages the memory. I think that fasm reserves a quater of the memory for source processing and the rest for assembling. If someone can confirm this could be great.
Post 11 Dec 2008, 23:34
View user's profile Send private message Reply with quote
madmatt



Joined: 07 Oct 2003
Posts: 1045
Location: Michigan, USA
madmatt
LocoDelAssembly wrote:

A mod? Why you couldn't made it with the official version? Note that the combo box only gives you some suggested values but you are free to type whatever number of KBs you want (with the obvious restrictions ofc but 1 GB is doable, just set memory to 1048576.


For two reasons, one, simply for convenience, and two, to learn a tiny bit about how fasmw does things, especially in the gui area (where all of my mods really are).

LocoDelAssembly wrote:
Because FASM needs to have loaded on memory every memory region of the executable. You could tell here why FASM don't just make some "hole" to save RAM, but actually it is not that simple because some load/store after that declaration could affect that initially uninitialized memory (and this is only what comes to my mind, Tomasz could have devised some other factors, what I'm sure is that it was hardly due to Tomasz's lazyness ).

After setting 1048576 of memory (which was fully allocated and not recursively halved till success as might occur), this is the highest memory allocation I got:

Code:
format binary 
rb 1024*1024*767    


I'm not very familiar with fasm internals but I think this limitation is caused because of the way fasm manages the memory. I think that fasm reserves a quater of the memory for source processing and the rest for assembling. If someone can confirm this could be great.


Thanks for the info LocoDel Smile . Yeh, maybe Tomasz could explain where in memory the excutable (and bss memory) goes, in the fasmw workspace, or does he simply call WinExec Confused . Or maybe this is a Windows issue? It's extremly rare I need this much memory. So, i wouldn't call this a bug that needs fixing, just more curious as too how memory is managed inside and outside the fasmw environment.

_________________
Gimme a sledge hammer! I'LL FIX IT!
Post 12 Dec 2008, 21:25
View user's profile Send private message 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.