Menu

#955 Heap allocation issue

18.2.2
closed
None
OSLIB
Low
17.6.4
True
2019-02-07
2018-06-30
rushmash
No

Hi,

After fixing issue #888 you have changed default allocator provider at chmemheap.c (chheap.c):

@@ -106,7 +106,7 @@ static memory_heap_t default_heap;
  */
 void _heap_init(void) {

-  default_heap.provider = chCoreAllocAligned;
+  default_heap.provider = chCoreAllocAlignedWithOffset;

Since then (I suppose) heap memory became more fragmented due to this code:

void *chHeapAllocAligned(memory_heap_t *heapp, size_t size, unsigned align)
...
/* More memory is required, tries to get it from the associated provider
     else fails.*/
  if (heapp->provider != NULL) {
    ahp = heapp->provider((pages + 1U) * CH_HEAP_ALIGNMENT,
                          align,
                          sizeof (heap_header_t));

As far as I understand +1U is not needed here, it means the size of a heap_header_t added to the size of allocated block (as it was before #888 fix when chCoreAllocAligned was used here). But now it's redundant because same is passed as 3rd argument (sizeof(heap_header_t)).

Please check it out.
Thanks!

Discussion

  • Giovanni Di Sirio

    Hi,

    Thanks for finding, fixed in repository for all active branches.

    Giovanni

     
  • Giovanni Di Sirio

    • assigned_to: Giovanni Di Sirio
    • Component: Other --> OSLIB
    • Severity: High --> Low
    • Affected Version: Trunk --> 17.6.4
    • Fixed in Repository: False --> True
     
  • Giovanni Di Sirio

    • Status: open --> closed
     

Log in to post a comment.