[exim-cvs] Memory handling: fix size backoff on store-reset

Startseite
Nachricht löschen
Nachricht beantworten
Autor: Exim Git Commits Mailing List
Datum:  
To: exim-cvs
Betreff: [exim-cvs] Memory handling: fix size backoff on store-reset
Gitweb: https://git.exim.org/exim.git/commitdiff/8cb34ed5d75213c1d779076ab2959da54af98a1e
Commit:     8cb34ed5d75213c1d779076ab2959da54af98a1e
Parent:     1e30b0199daf7a7a882458251a3dc10d45d4c7d1
Author:     Jeremy Harris <jgh146exb@???>
AuthorDate: Sun Mar 28 00:56:14 2021 +0000
Committer:  Jeremy Harris <jgh146exb@???>
CommitDate: Sun Mar 28 16:04:01 2021 +0100


    Memory handling: fix size backoff on store-reset
---
 src/src/store.c | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)


diff --git a/src/src/store.c b/src/src/store.c
index 9de3f3f..22615ea 100644
--- a/src/src/store.c
+++ b/src/src/store.c
@@ -282,7 +282,9 @@ these functions are mostly called for small amounts of store. */

 if (size > yield_length[pool])
   {
-  int length = MAX(STORE_BLOCK_SIZE(store_block_order[pool]), size);
+  int length = MAX(
+      STORE_BLOCK_SIZE(store_block_order[pool]) - ALIGNED_SIZEOF_STOREBLOCK,
+      size);
   int mlength = length + ALIGNED_SIZEOF_STOREBLOCK;
   storeblock * newblock;


@@ -545,15 +547,10 @@ if ( yield_length[pool] < STOREPOOL_MIN_SIZE
bb = b->next;
b->next = NULL;

-/* If there will be only one block left in the pool, drop one
-most-recent allocation size increase, ensuring it does not increase
-forever. */
-
-if (!bb && store_block_order[pool] > 12) store_block_order[pool]--;
-
 while ((b = bb))
   {
   int siz = b->length + ALIGNED_SIZEOF_STOREBLOCK;
+
 #ifndef COMPILE_UTILITY
   if (debug_store)
     assert_no_variables(b, b->length + ALIGNED_SIZEOF_STOREBLOCK,
@@ -564,6 +561,10 @@ while ((b = bb))
   pool_malloc -= siz;
   nblocks[pool]--;
   internal_store_free(b, func, linenumber);
+
+#ifndef RESTRICTED_MEMORY
+  if (store_block_order[pool] > 13) store_block_order[pool]--;
+#endif
   }


 /* Cut out the debugging stuff for utilities, but stop picky compilers from
@@ -739,7 +740,7 @@ for (storeblock * b = chainbase[pool]; b; b = b->next)
       memset(bb, 0xF0, bb->length+ALIGNED_SIZEOF_STOREBLOCK);
 #endif  /* COMPILE_UTILITY */


-    free(bb);
+    internal_store_free(bb, func, linenumber);
     return;
     }
   }
@@ -898,7 +899,7 @@ DEBUG(D_memory)
  debug_printf("----Exit npools  max: %3d kB\n", max_pool_malloc/1024);
  for (int i = 0; i < NPOOLS; i++)
   debug_printf("----Exit  pool %d max: %3d kB in %d blocks at order %u\t%s %s\n",
-    i, maxbytes[i]/1024, maxblocks[i], maxorder[i],
+    i, (maxbytes[i]+1023)/1024, maxblocks[i], maxorder[i],
     poolclass[i], pooluse[i]);
  }
 #endif