OS_Heap changes to blocksizes
Martin Avison (27) 1491 posts |
I noticed that recent changes to OS_Heap changed heap block allocation to In my Reporter module v2.66 the *ReportHeap command displays information I have changed Reporter to check only for length multiples of 4, and a new As part of the testing of this change, I wondered if the OS_Heap change had Is this rounding to 32 still required for the RMA? If it could be removed, the space usage for the RMA may be reduced by a But there is probably some good reason why it has to be there!? |
Steve Revill (20) 1361 posts |
I suspect this is a crude attempt to reduce fragmentation, by helping to ensure that any holes left by freed blocks are likely to be exactly the right size for some incoming claim, rather than a few bytes too big (fragmentation) or too small (slowing allocation down). |
Jeffrey Lee (213) 6048 posts |
I have a feeling it could be that as well. Either that or someone got confused between bytes and words. If (a) OS_Heap is a poor choice of heap manager for the RMA, and (b) it isn’t publicly documented that the RMA is just an ordinary OS_Heap, then we could easily change the RMA to be managed by a different, more appropriate heap manager. However we’d have to check that both (a) and (b) are true before making any changes. If 55% of 2000 blocks are wasting (up to) 32 bytes then that would only be 32K of memory being wasted, which isn’t something to get too worried about. I’ll probably build a ROM or two with that rounding code disabled and see how much of a difference it really makes. It also wouldn’t surprise me if that rounding up is also hiding quite a few buffer overflow bugs. |
Martin Avison (27) 1491 posts |
I’ll probably build a ROM or two with that rounding code disabled and see how much of a difference it really makes. Would certainly help to identify if there was any specific reason why it is rounded. Fragmentation is a possibility, but it would be good to know! |
Martin Avison (27) 1491 posts |
I have changed Reporter to check only for length multiples of 4, and a new There is now a new version of Reporter, v2.66d, available on my website for anyone who uses *ReportHeap and wants to avoid heap validation errors when using RO5.18 or later. |
Stuart Swales (1481) 351 posts |
In ye olde days of MEMC and RISC OS 2, RMA allocations were rounded such that they were guaranteed to start on a 16-byte boundary. There were slight timing differences in memory access on MEMC which could be exploited to fractionally speed up time-critical code (I think ADFS used this) |
Stuart Swales (1481) 351 posts |
OK, a pedant writes – at a guaranteed offset (+4) from a 16-byte boundary… |
Timothy Baldwin (184) 242 posts |
8 byte alignment is required for ARM double word load and store instructions. |