10 October 2023, 16:11 | #21 |
ex. demoscener "Bigmama"
Join Date: Jun 2012
Location: Fyn / Denmark
Posts: 1,624
|
|
10 October 2023, 17:09 | #22 |
Registered User
Join Date: Jun 2016
Location: europe
Posts: 1,039
|
Did the same test on KS1.3, the same outcome (3 headers).
|
10 October 2023, 17:11 | #23 |
Registered User
Join Date: Jan 2019
Location: Germany
Posts: 3,233
|
No, just incorrect information. Exec only tracks free chunks.
However, you should really not depend on the internals of the allocator, especially on the rounding policy. What you get is sufficiently aligned to make all members of the 680x0 happy, with the exception of MOVE16 which you should not use anyhow. The rule is very simple: What you allocate with AllocMem you release with FreeMem, exactly the same pointer, the same length. What you allocated with AllocVec you release with FreeVec, same address, exec keeps care of the length. What you allocated with AllocAbs you release with FreeMem, namely the address you requested and the size you requested *AND NOT* the address you received from AllocAbs(!) which may be slightly off, but contains the requested range *if* allocation was successful. Do not depend on the implementation details of the allocator. There are custom allocators out in the wild that may operate (more or less) different. |
11 October 2023, 01:20 | #24 | |
Registered User
Join Date: Jun 2016
Location: europe
Posts: 1,039
|
Quote:
These were done before I made my previous post, so here they are redone on A500+KS1.3 and documented just to show I didn't pull it out of my... back socket. 1. preliminary run to get the approx. address (lets call it X) of an allocated 1024 bytes block 2. zero out all free memory 3. doublecheck a few KB around the address X, all zeroes 4. run again, breakpoint right after X=AllocMem(1024)/Forbid() and filling 1024 bytes at X with a pattern 5. contents at X: pattern 1024 bytes, $0.L, $732a8.L 6. call FreeMem(X,1024) 7. contents at X: 0.L, $736a8.L (=$732a8+1024), pattern 1016 bytes, 0.L, $732a8.L 8. clear 8 bytes at X+1024 (last 2 .L from step 7) 9. contents at X: 0.L, $736a8.L, pattern 1016 bytes, 0.L, 0.L 10. call first AllocAbs(X,512), returned d0 == passed a1 11. contents at X: (X+512).L, $736a8.L, pattern 504 bytes, 0.L, $734a8.L (=$736a8-512), pattern 504 bytes, 0.L, 0.L 12. call second AllocAbs(X+512,512), returned d0 == passed a1 13. contents at X: (X+512).L, $736a8.L, pattern 504 bytes, (X+1024).L, $734a8.L (=$736a8-512), pattern 504 bytes, 0.L, $732a8.L (=$734a8-512=$736a8-1024) So, again. After the first AllocAbs() those 8 bytes that magically appeared at X+512 sure look like a private tracking info, why was I able to AbsAlloc() at that very same address. Genuinely confused. Especially (shame on me) because the 4 instructions at label aa_splitsucc in memory.asm line 1405 look just like some kind of tracking. |
|
11 October 2023, 05:49 | #25 | |
Registered User
Join Date: Mar 2019
Location: Poland
Posts: 59
|
Quote:
When you did the first AllocAbs, the block of free memory that contained the requested start address had to be split into three blocks - one allocated and two free blocks (one before allocated block and the second after allocated block). Free blocks were linked into free blocks list, so at the beginning of each free block the MemChunk struct was initialized. The MemChunk struct is only valid for free blocks, so you were able to allocate the second free block with this struct at the beginning. |
|
11 October 2023, 12:20 | #26 |
Registered User
Join Date: Jun 2016
Location: europe
Posts: 1,039
|
Yes, that makes sense. I realized it when I woke up today and thought that allocating the second half first would've made a more interesting test case.
And the autodocs stating "The 8 bytes past the end of an AllocAbs will be changed by Exec relinking the next block of memory." certainly didn't help. I mean, it's correct but could've been a little more informative (e.g. "next free block"). |
11 October 2023, 12:57 | #27 |
Registered User
Join Date: Apr 2023
Location: "Hamcastle"
Posts: 20
|
@a/b and Olaf Barthel
Thanks for the replies and your time. Hope, I have not opened a can of worms with my naive question :-| Anyway, the good news are: The cat is still alive :-) |
11 October 2023, 13:19 | #28 |
Registered User
Join Date: Mar 2019
Location: Poland
Posts: 59
|
This scheme of keeping information on free memory is also the reason why the minimal allocated block size is 8 bytes - when freeing allocated chunk must have enough space to hold the struct MemChunk, which is 8 bytes in size ...
|
11 October 2023, 21:15 | #29 |
Registered User
Join Date: Sep 2009
Location: Norway
Posts: 1,711
|
Oh man, what have I done with making this thread...
|
11 October 2023, 23:06 | #30 | |
Registered User
Join Date: May 2013
Location: Grimstad / Norway
Posts: 839
|
Quote:
Well, it worked just fine; the only problem was that there are so many small allocs during boot that the 16M was not enough to complete bring-up. |
|
12 October 2023, 01:29 | #31 |
Registered User
Join Date: Jan 2019
Location: Germany
Posts: 3,233
|
Things should be better in 3.2 now as the two most important sources of fragmentation are gone. These are the cliprects of the layers library, and the region and region rectangles of graphics. Both are responsible for window and layer clipping.
|
12 October 2023, 02:23 | #32 |
Registered User
Join Date: Jun 2016
Location: europe
Posts: 1,039
|
We just took a (not-really-)shortcut to get back to the start. Based on your description in #7, I don't see why my suggestion in #2 wouldn't work. So, again...
E.g. you allocmem a 256KB buffer, free it, then allocabs 2x 128KB. Now you hold the same completely consecutive 256KB, no gaps or anything, and you can start filling them with data and then you process it. There was nothing there before nor is there anything inbetween now to get corrupted. Then you normalize 16-bit to 8-bit, basically shrink down data to a half, so now it completely fits into the first absolute buffer, and you free the second one, as far as I understand your description. Of course, you have to ensure that the sizes and the second address are 64-bit aligned (=> 128-bit align the full size so it's divisible by 2). If any allocabs fails, you can fall back to a full buffer and set a flag so you know what to do later on. You could also check if a system has KS >= 2.0 and more than 512KB (or whatever you think is a minimum) and if so you just work with a full buffer (to cover a theoretical case of your app running on some imaginary tripple next-gen Amiga with a weird non-compatible memory pool handler, because I doubt something like a 512KB KS1.3 system will have one). I don't see a problem with this approach, if all alloc calls succeed, and they should, it will work. |
12 October 2023, 09:54 | #33 |
ex. demoscener "Bigmama"
Join Date: Jun 2012
Location: Fyn / Denmark
Posts: 1,624
|
This only affects chipmem on a system without 3rd party patches, right!?
|
12 October 2023, 19:35 | #34 |
Registered User
Join Date: Jan 2019
Location: Germany
Posts: 3,233
|
No, it only affects regular memory. All these structures are relatively tiny administration structures. The bitmaps, if needed, are allocated in addition.
|
12 October 2023, 19:51 | #35 | |
Registered User
Join Date: Sep 2009
Location: Norway
Posts: 1,711
|
Quote:
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
IFF ANIM Chunk structure - DPPS and DPXT | Steffest | Graphics | 0 | 06 July 2023 14:56 |
Chunk True Color 4 pixels | remz | Coders. Asm / Hardware | 31 | 08 June 2022 13:04 |
hdf - ways to reduce filesize | Nova | support.WinUAE | 8 | 22 December 2018 02:51 |
Reduce size of an IFF image? | BarryB | support.Apps | 18 | 19 September 2015 03:54 |
How can I reduce the number of reboots on start-up? | keropi | support.Apps | 2 | 08 December 2005 13:19 |
|
|