The MASM Forum

General => The Campus => Topic started by: bsdsource on January 14, 2014, 06:50:43 PM

Title: variable in .data? section vs heap
Post by: bsdsource on January 14, 2014, 06:50:43 PM
In my project I currently use the following variable:

.data?
     buffer_memory dd 40960 dup (?)


Would it be better to use the heap api commands and allocate memory like that, or is this method fine?
Title: Re: variable in .data? section vs heap
Post by: jj2007 on January 14, 2014, 07:49:38 PM
It's fine, shorter and faster. Watch out for a bug in Masm (http://www.masmforum.com/board/index.php?topic=10435.0) (2. Assembly gets slow...)
Title: Re: variable in .data? section vs heap
Post by: bsdsource on January 15, 2014, 01:27:47 AM
Thanks for the info   :t
Title: Re: variable in .data? section vs heap
Post by: hutch-- on January 15, 2014, 11:29:45 AM
Do yourself a favour, get used to using allocated memory, its a lot more flexible and you can start and end it on the basis of need. Either initialised or uninitialised data sections are useful for relatively small amounts of memory when you need GLOBAL scope with the data or space enclosed in either but dynamic allocation can do a lot more in a much more flexible way.
Title: Re: variable in .data? section vs heap
Post by: Force on January 15, 2014, 09:49:29 PM
what about  reading file ?

i use like that

invoke GlobalAlloc,GMEM_MOVEABLE or GMEM_ZEROINIT,(1024*1024* 8 )

if i use like that

invoke GlobalAlloc,GMEM_MOVEABLE or GMEM_ZEROINIT,nFileSize

after deleting any item from file my project crashes  :dazzled: