| View previous topic :: View next topic |
| Author |
Message |
rog9001 Expert Cheater
Reputation: 2
Joined: 22 Dec 2015 Posts: 214 Location: Jupiter
|
Posted: Fri Nov 25, 2016 3:56 pm Post subject: [allocacted memory] what does it mean? |
|
|
so something I never tried doing is changing the number after what is being allocated
alloc(mem,[NUMBER])
but now I tried and it didn't change anything. I tried having it be
alloc(mem,1000)
and also
alloc(mem,1)
and there was no change. everything worked. What does the number mean?
Last edited by rog9001 on Fri Nov 25, 2016 4:38 pm; edited 1 time in total |
|
| Back to top |
|
 |
ulysse31 Master Cheater
Reputation: 2
Joined: 19 Mar 2015 Posts: 324 Location: Paris
|
Posted: Fri Nov 25, 2016 4:23 pm Post subject: |
|
|
the amount of bytes being allocated.
In the ram the minimum amount of bytes of 1 page is 0x1000 (it's 0x200 on disk) therefore wether you use 0x1000 or less will not matter, a new page is being allocated either way.
|
|
| Back to top |
|
 |
Dark Byte Site Admin
Reputation: 474
Joined: 09 May 2003 Posts: 25952 Location: The netherlands
|
Posted: Fri Nov 25, 2016 4:24 pm Post subject: |
|
|
the number is important to other allocs in the same script
| Code: |
alloc(mem,4)
alloc(mem2,1)
alloc(mem3,4)
|
mem2 will be 4 bytes after mem and mem3 will be 5 bytes after mem)
if you write a 4 byte value to mem2 it will affect mem3, so make sure you allocate enough.
also, if you allocate 4097 bytes it will actually allocate 8192 bytes.
_________________
Tools give you results. Knowledge gives you control.
Like my help? Join me on Patreon so i can keep helping |
|
| Back to top |
|
 |
mgr.inz.Player I post too much
Reputation: 222
Joined: 07 Nov 2008 Posts: 4438 Location: W kraju nad Wisla. UTC+01:00
|
Posted: Fri Nov 25, 2016 4:29 pm Post subject: |
|
|
If only one alloc in the script there's no difference between those:
alloc(mem,1000)
alloc(mem,1)
alloc(mem,4096)
All of them will allocate only one page (usually 4096 bytes)
alloc(mem,4097)
alloc(mem,8192)
Those will allocate two pages
If two or more allocs in the script:
alloc(mem_first,128)
alloc(mem_second,512)
CE will allocate one page (128+512 will still fit in one page)
mem_second will be exactly 128 bytes below mem_first
_________________
|
|
| Back to top |
|
 |
rog9001 Expert Cheater
Reputation: 2
Joined: 22 Dec 2015 Posts: 214 Location: Jupiter
|
Posted: Fri Nov 25, 2016 4:32 pm Post subject: |
|
|
Thanks for all the replies. Now I get it.
|
|
| Back to top |
|
 |
Kavvman Master Cheater
Reputation: 2
Joined: 17 Apr 2004 Posts: 316
|
Posted: Sat Nov 26, 2016 3:47 am Post subject: |
|
|
| Dark Byte wrote: | the number is important to other allocs in the same script
| Code: |
alloc(mem,4)
alloc(mem2,1)
alloc(mem3,4)
|
mem2 will be 4 bytes after mem and mem3 will be 5 bytes after mem)
if you write a 4 byte value to mem2 it will affect mem3, so make sure you allocate enough.
also, if you allocate 4097 bytes it will actually allocate 8192 bytes. |
That's really smart! Instead of wasting the whole page, it reuses it
_________________
... |
|
| Back to top |
|
 |
|