27 #define __STDC_LIMIT_MACROS 38 #ifndef NO_CONFIG_HEADER 39 #include "scip/config.h" 61 #ifdef ENABLE_MEMLIST_CHECKS 74 #ifdef SCIPdebugMessage 75 #define debugMessage SCIPdebugMessage 76 #define errorMessage SCIPerrorMessage 78 #define debugMessage while( FALSE ) printf 79 #define errorMessage printf 80 #define printErrorHeader(f,l) printf("[%s:%d] ERROR: ", f, l) 81 #define printError printf 84 #ifdef ENABLE_MEMLIST_CHECKS 85 #define warningMessage printf 87 #define printInfo printf 95 #define MAX(x,y) ((x) >= (y) ? (x) : (y)) 96 #define MIN(x,y) ((x) <= (y) ? (x) : (y)) 99 #ifndef SCIP_LONGINT_FORMAT 100 #if defined(_WIN32) || defined(_WIN64) 101 #define LONGINT_FORMAT "I64d" 103 #define LONGINT_FORMAT "lld" 106 #define LONGINT_FORMAT SCIP_LONGINT_FORMAT 109 #ifndef SCIP_MAXMEMSIZE 111 #define MAXMEMSIZE SIZE_MAX / 2 113 #define MAXMEMSIZE SCIP_MAXMEMSIZE 118 #if defined(_WIN32) || defined(_WIN64) || defined(__STDC__) 119 #define INLINE __inline 121 #define INLINE inline 132 #if !defined(NDEBUG) && defined(ENABLE_MEMLIST_CHECKS) 134 typedef struct Memlist MEMLIST;
146 static MEMLIST* memlist =
NULL;
147 static size_t memused = 0;
156 MEMLIST* list = memlist;
159 while( list !=
NULL )
164 assert(used == memused);
167 #define checkMemlist() 175 const char* filename,
181 assert(ptr !=
NULL && size > 0);
183 list = (MEMLIST*)malloc(
sizeof(MEMLIST));
184 assert(list !=
NULL);
188 list->filename = strdup(filename);
189 assert(list->filename !=
NULL);
191 list->next = memlist;
201 const char* filename,
212 while( list !=
NULL && ptr != list->ptr )
214 listptr = &(list->next);
219 assert(ptr == list->ptr);
221 *listptr = list->next;
222 assert( list->size <= memused );
223 memused -= list->size;
224 free(list->filename);
230 printError(
"Tried to free unknown pointer <%p>.\n", ptr);
243 while( list !=
NULL && ptr != list->ptr )
261 while( list !=
NULL )
263 printInfo(
"%12p %8llu %s:%d\n", list->ptr, (
unsigned long long) list->size, list->filename, list->line);
267 printInfo(
"Total: %8llu\n", (
unsigned long long) memused);
268 if( used != memused )
270 errorMessage(
"Used memory in list sums up to %llu instead of %llu\n", (
unsigned long long)used, (
unsigned long long)memused);
280 if( memlist !=
NULL || memused > 0 )
282 warningMessage(
"Memory list not empty.\n");
292 return (
long long) memused;
297 #define addMemlistEntry(ptr, size, filename, line) do { (void) (ptr); (void) (size); (void) (filename); (void) (line); } while(0) 298 #define removeMemlistEntry(ptr, filename, line) do { (void) (ptr); (void) (filename); (void) (line); } while(0) 318 printInfo(
"Optimized, threadsafe version of memory shell linked - no memory diagnostics available.\n");
342 const char* filename,
348 assert(typesize > 0);
350 debugMessage(
"calloc %llu elements of %llu bytes [%s:%d]\n", (
unsigned long long)num, (
unsigned long long)typesize,
363 typesize =
MAX(typesize, 1);
364 ptr = calloc(num, typesize);
369 printError(
"Insufficient memory for allocation of %llu bytes.\n", (
unsigned long long)(num) * (typesize));
380 const char* filename,
386 debugMessage(
"malloc %llu bytes [%s:%d]\n", (
unsigned long long)size, filename, line);
403 printError(
"Insufficient memory for allocation of %llu bytes.\n", (
unsigned long long)size);
415 const char* filename,
422 debugMessage(
"malloc %llu elements of %llu bytes [%s:%d]\n",
423 (
unsigned long long)num, (
unsigned long long)typesize, filename, line);
434 size = num * typesize;
441 printError(
"Insufficient memory for allocation of %llu bytes.\n", (
unsigned long long)size);
453 const char* filename,
472 newptr = realloc(ptr, size);
477 printError(
"Insufficient memory for reallocation of %llu bytes.\n", (
unsigned long long)size);
490 const char* filename,
509 size = num * typesize;
511 newptr = realloc(ptr, size);
516 printError(
"Insufficient memory for reallocation of %llu bytes.\n", (
unsigned long long)size);
533 memset(ptr, 0, size);
547 assert(source !=
NULL);
548 memcpy(ptr, source, size);
564 assert(source !=
NULL);
565 memmove(ptr, source, size);
573 const char* filename,
579 assert(source !=
NULL || size == 0);
593 const char* filename,
599 assert(source !=
NULL || num == 0);
611 const char* filename,
615 assert( ptr !=
NULL );
633 const char* filename,
637 assert( ptr !=
NULL );
654 #define CHKHASH_POWER 10 655 #define CHKHASH_SIZE (1<<CHKHASH_POWER) 662 long long memallocated;
663 long long maxmemused;
664 long long maxmemunused;
665 long long maxmemallocated;
682 #define CHUNKLENGTH_MIN 1024 683 #define CHUNKLENGTH_MAX 1048576 684 #define STORESIZE_MAX 8192 685 #define GARBAGE_SIZE 256 686 #define ALIGNMENT (sizeof(FREELIST)) 737 #define CHUNK_LT(ptr,chunk) ptr < chunk->store 738 #define CHUNK_GT(ptr,chunk) ptr >= chunk->storeend 782 assert(chunk !=
NULL);
783 assert(chunk->store <= chunk->storeend);
785 return (ptr >= (
void*)(chunk->store) && ptr < (
void*)(chunk->storeend));
801 assert(chkmem !=
NULL);
804 if( rbTreeFindChunk(chkmem->rootchunk, ptr, &chunk) == 0 )
818 assert(chkmem !=
NULL);
839 assert(chunk !=
NULL);
840 assert(chunk->store !=
NULL);
841 assert(chunk->storeend == (
void*)((
char*)(chunk->store) + chunk->elemsize * chunk->storesize));
842 assert(chunk->chkmem !=
NULL);
843 assert(chunk->chkmem->elemsize == chunk->elemsize);
845 if( chunk->eagerfree ==
NULL )
846 assert(chunk->nexteager ==
NULL && chunk->preveager ==
NULL);
847 else if( chunk->preveager ==
NULL )
848 assert(chunk->chkmem->firsteager == chunk);
850 if( chunk->nexteager !=
NULL )
851 assert(chunk->nexteager->preveager == chunk);
852 if( chunk->preveager !=
NULL )
853 assert(chunk->preveager->nexteager == chunk);
856 eager = chunk->eagerfree;
857 while( eager !=
NULL )
863 assert(chunk->eagerfreesize == eagerfreesize);
878 assert(chkmem !=
NULL);
889 storesize += chunk->storesize;
890 eagerfreesize += chunk->eagerfreesize;
893 assert(chkmem->nchunks == nchunks);
894 assert(chkmem->storesize == storesize);
895 assert(chkmem->eagerfreesize == eagerfreesize);
897 assert(((
unsigned int) (chkmem->eagerfreesize == 0)) ^ ( (
unsigned int) (chkmem->firsteager !=
NULL)));
899 if( chkmem->firsteager !=
NULL )
900 assert(chkmem->firsteager->preveager ==
NULL);
902 lazy = chkmem->lazyfree;
903 while( lazy !=
NULL )
906 assert(chunk !=
NULL);
907 assert(chunk->chkmem == chkmem);
911 assert(chkmem->lazyfreesize == lazyfreesize);
914 #define checkChunk(chunk) 915 #define checkChkmem(chkmem) 931 assert(chkmem !=
NULL);
932 assert(chunk !=
NULL);
933 assert(chunk->store !=
NULL);
935 debugMessage(
"linking chunk %p to chunk block %p [elemsize:%d, %d chunks]\n",
936 (
void*)chunk, (
void*)chkmem, chkmem->elemsize, chkmem->nchunks);
938 pos = rbTreeFindChunk(chkmem->rootchunk, chunk->store, &parent);
944 chkmem->storesize += chunk->storesize;
957 assert(chunk !=
NULL);
958 assert(chunk->eagerfree ==
NULL);
959 assert(chunk->nexteager ==
NULL);
960 assert(chunk->preveager ==
NULL);
962 chkmem = chunk->chkmem;
963 assert(chkmem !=
NULL);
964 assert(chkmem->elemsize == chunk->elemsize);
966 debugMessage(
"unlinking chunk %p from chunk block %p [elemsize:%d, %d chunks]\n",
967 (
void*)chunk, (
void*)chkmem, chkmem->elemsize, chkmem->nchunks);
973 chkmem->storesize -= chunk->storesize;
983 assert(chunk->chkmem == chkmem);
984 assert(chunk->nexteager ==
NULL);
985 assert(chunk->preveager ==
NULL);
987 chunk->nexteager = chkmem->firsteager;
988 chunk->preveager =
NULL;
989 if( chkmem->firsteager !=
NULL )
991 assert(chkmem->firsteager->preveager ==
NULL);
992 chkmem->firsteager->preveager = chunk;
994 chkmem->firsteager = chunk;
1003 assert(chunk !=
NULL);
1004 assert(chunk->eagerfreesize == 0 || chunk->eagerfreesize == chunk->storesize);
1006 if( chunk->nexteager !=
NULL )
1007 chunk->nexteager->preveager = chunk->preveager;
1008 if( chunk->preveager !=
NULL )
1009 chunk->preveager->nexteager = chunk->nexteager;
1012 assert(chunk->chkmem->firsteager == chunk);
1013 chunk->chkmem->firsteager = chunk->nexteager;
1015 chunk->nexteager =
NULL;
1016 chunk->preveager =
NULL;
1017 chunk->eagerfree =
NULL;
1035 assert(chkmem !=
NULL);
1037 debugMessage(
"creating new chunk in chunk block %p [elemsize: %d]\n", (
void*)chkmem, chkmem->elemsize);
1040 if( chkmem->nchunks == 0 )
1041 storesize = chkmem->initchunksize;
1043 storesize = 2 * chkmem->lastchunksize;
1044 assert(storesize > 0);
1048 storesize =
MAX(storesize, 1);
1049 chkmem->lastchunksize = storesize;
1053 assert( chkmem->elemsize < INT_MAX / storesize );
1054 assert(
sizeof(
CHUNK) <
MAXMEMSIZE - (
size_t)(storesize * chkmem->elemsize) );
1056 if( newchunk ==
NULL )
1060 newchunk->store = (
void*) ((
char*) newchunk +
sizeof(
CHUNK));
1061 newchunk->storeend = (
void*) ((
char*) newchunk->store + storesize * chkmem->elemsize);
1062 newchunk->eagerfree =
NULL;
1063 newchunk->nexteager =
NULL;
1064 newchunk->preveager =
NULL;
1065 newchunk->chkmem = chkmem;
1066 newchunk->elemsize = chkmem->elemsize;
1067 newchunk->storesize = storesize;
1068 newchunk->eagerfreesize = 0;
1070 if( memsize !=
NULL )
1071 (*memsize) += ((
long long)(
sizeof(
CHUNK) + (
long long)storesize * chkmem->elemsize));
1073 debugMessage(
"allocated new chunk %p: %d elements with size %d\n", (
void*)newchunk, newchunk->storesize, newchunk->elemsize);
1078 for( i = 0; i < newchunk->storesize - 1; ++i )
1080 freelist = (
FREELIST*) newchunk->store + i * chkmem->elemsize /
sizeof(
FREELIST*);
1081 freelist->next = (
FREELIST*) newchunk->store + (i + 1) * chkmem->elemsize /
sizeof(
FREELIST*);
1084 freelist = (
FREELIST*) newchunk->store + (newchunk->storesize - 1) * chkmem->elemsize /
sizeof(
FREELIST*);
1085 freelist->next = chkmem->lazyfree;
1086 chkmem->lazyfree = (
FREELIST*) (newchunk->store);
1087 chkmem->lazyfreesize += newchunk->storesize;
1104 assert(chunk !=
NULL);
1108 if( memsize !=
NULL )
1109 (*memsize) -= ((
long long)
sizeof(
CHUNK) + (
long long)chunk->storesize * chunk->elemsize);
1122 assert(chunk !=
NULL);
1123 assert(chunk->store !=
NULL);
1124 assert(chunk->eagerfree !=
NULL);
1125 assert(chunk->chkmem !=
NULL);
1126 assert(chunk->chkmem->rootchunk !=
NULL);
1127 assert(chunk->chkmem->firsteager !=
NULL);
1128 assert(chunk->eagerfreesize == chunk->storesize);
1130 debugMessage(
"freeing chunk %p of chunk block %p [elemsize: %d]\n", (
void*)chunk, (
void*)chunk->chkmem, chunk->chkmem->elemsize);
1133 chunk->chkmem->eagerfreesize -= chunk->eagerfreesize;
1134 assert(chunk->chkmem->eagerfreesize >= 0);
1154 assert(chunk !=
NULL);
1155 assert(chunk->eagerfree !=
NULL);
1156 assert(chunk->eagerfreesize > 0);
1157 assert(chunk->chkmem !=
NULL);
1159 debugMessage(
"allocating chunk element in chunk %p [elemsize: %d]\n", (
void*)chunk, chunk->chkmem->elemsize);
1162 ptr = chunk->eagerfree;
1163 chunk->eagerfree = ptr->next;
1164 chunk->eagerfreesize--;
1165 chunk->chkmem->eagerfreesize--;
1167 assert((chunk->eagerfreesize == 0 && chunk->eagerfree ==
NULL)
1168 || (chunk->eagerfreesize != 0 && chunk->eagerfree !=
NULL));
1169 assert(chunk->chkmem->eagerfreesize >= 0);
1172 if( chunk->eagerfree ==
NULL )
1174 assert(chunk->eagerfreesize == 0);
1190 assert(chunk !=
NULL);
1191 assert(chunk->chkmem !=
NULL);
1194 debugMessage(
"freeing chunk element %p of chunk %p [elemsize: %d]\n", (
void*)ptr, (
void*)chunk, chunk->chkmem->elemsize);
1197 if( chunk->eagerfree ==
NULL )
1199 assert(chunk->eagerfreesize == 0);
1204 ((
FREELIST*)ptr)->next = chunk->eagerfree;
1206 chunk->eagerfreesize++;
1207 chunk->chkmem->eagerfreesize++;
1228 if( chkmem ==
NULL )
1231 chkmem->lazyfree =
NULL;
1232 chkmem->rootchunk =
NULL;
1233 chkmem->firsteager =
NULL;
1234 chkmem->nextchkmem =
NULL;
1235 chkmem->elemsize = size;
1236 chkmem->nchunks = 0;
1237 chkmem->lastchunksize = 0;
1238 chkmem->storesize = 0;
1239 chkmem->lazyfreesize = 0;
1240 chkmem->eagerfreesize = 0;
1241 chkmem->initchunksize = initchunksize;
1242 chkmem->garbagefactor = garbagefactor;
1244 chkmem->filename =
NULL;
1246 chkmem->ngarbagecalls = 0;
1247 chkmem->ngarbagefrees = 0;
1250 if( memsize !=
NULL )
1263 assert(chkmem !=
NULL);
1268 SCIPrbtreeDelete(&chkmem->rootchunk, chunk);
1269 destroyChunk(chunk, memsize);
1272 chkmem->lazyfree =
NULL;
1273 chkmem->firsteager =
NULL;
1274 chkmem->nchunks = 0;
1275 chkmem->lastchunksize = 0;
1276 chkmem->storesize = 0;
1277 chkmem->lazyfreesize = 0;
1278 chkmem->eagerfreesize = 0;
1288 assert(chkmem !=
NULL);
1289 assert(*chkmem !=
NULL);
1297 if( memsize !=
NULL )
1298 (*memsize) -= (
long long)(
sizeof(
BMS_CHKMEM));
1312 assert(chkmem !=
NULL);
1315 if( chkmem->lazyfree ==
NULL )
1317 assert(chkmem->lazyfreesize == 0);
1320 if( chkmem->firsteager !=
NULL )
1329 assert(chkmem->lazyfree !=
NULL);
1330 assert(chkmem->lazyfreesize > 0);
1332 ptr = chkmem->lazyfree;
1333 chkmem->lazyfree = ptr->next;
1334 chkmem->lazyfreesize--;
1354 assert(chkmem !=
NULL);
1356 debugMessage(
"garbage collection for chunk block %p [elemsize: %d]\n", (
void*)chkmem, chkmem->elemsize);
1359 if( chkmem->lazyfreesize + chkmem->eagerfreesize == chkmem->storesize )
1366 chkmem->ngarbagecalls++;
1370 while( chkmem->lazyfree !=
NULL )
1373 lazyfree = chkmem->lazyfree;
1374 chkmem->lazyfree = chkmem->lazyfree->next;
1375 chkmem->lazyfreesize--;
1378 chunk =
findChunk(chkmem, (
void*)lazyfree);
1382 errorMessage(
"chunk for lazy free chunk %p not found in chunk block %p\n", (
void*)lazyfree, (
void*)chkmem);
1385 assert(chunk !=
NULL);
1389 assert(chunk->eagerfreesize > 0);
1391 assert(chkmem->lazyfreesize == 0);
1394 chunk = chkmem->firsteager;
1395 while( chunk !=
NULL && chkmem->nchunks > 1 )
1397 nexteager = chunk->nexteager;
1398 if( chunk->eagerfreesize == chunk->storesize )
1401 chkmem->ngarbagefrees++;
1417 const char* filename,
1421 assert(chkmem !=
NULL);
1422 assert(ptr !=
NULL);
1424 #if ( defined(CHECKMEM) || defined(CHECKCHKFREE) ) 1429 printError(
"Pointer %p does not belong to chunk block %p (size: %d).\n", ptr, chkmem, chkmem->elemsize);
1434 ((
FREELIST*)ptr)->next = chkmem->lazyfree;
1436 chkmem->lazyfreesize++;
1439 if( chkmem->garbagefactor >= 0 && chkmem->nchunks > 0 && chkmem->lazyfreesize >=
GARBAGE_SIZE 1440 && chkmem->lazyfreesize + chkmem->eagerfreesize
1441 > chkmem->garbagefactor * (
double)(chkmem->storesize) / (
double)(chkmem->nchunks) )
1455 const char* filename,
1463 if( chkmem ==
NULL )
1466 printError(
"Insufficient memory for chunk block.\n");
1468 debugMessage(
"created chunk memory %p [elemsize: %d]\n", (
void*)chkmem, (
int)size);
1476 const char* filename,
1480 debugMessage(
"clearing chunk memory %p [elemsize: %d]\n", (
void*)chkmem, chkmem->elemsize);
1482 if( chkmem !=
NULL )
1487 printError(
"Tried to clear null chunk block.\n");
1494 const char* filename,
1498 assert(chkmem !=
NULL);
1500 debugMessage(
"destroying chunk memory %p [elemsize: %d]\n", (
void*)*chkmem, (*chkmem)->elemsize);
1502 if( *chkmem !=
NULL )
1507 printError(
"Tried to destroy null chunk block.\n");
1515 const char* filename,
1521 assert(chkmem !=
NULL);
1522 assert((
int)size == chkmem->elemsize);
1529 printError(
"Insufficient memory for new chunk.\n");
1531 debugMessage(
"alloced %8llu bytes in %p [%s:%d]\n", (
unsigned long long)size, (
void*)ptr, filename, line);
1543 const char* filename,
1549 assert(chkmem !=
NULL);
1550 assert(source !=
NULL);
1551 assert((
int)size == chkmem->elemsize);
1565 const char* filename,
1569 assert(chkmem !=
NULL);
1570 assert((
int)size == chkmem->elemsize);
1571 assert( ptr !=
NULL );
1575 debugMessage(
"free %8d bytes in %p [%s:%d]\n", chkmem->elemsize, *ptr, filename, line);
1585 printError(
"Tried to free null chunk pointer.\n");
1594 const char* filename,
1598 assert(chkmem !=
NULL);
1599 assert((
int)size == chkmem->elemsize);
1600 assert( ptr !=
NULL );
1604 debugMessage(
"free %8d bytes in %p [%s:%d]\n", chkmem->elemsize, *ptr, filename, line);
1618 debugMessage(
"garbage collection on chunk memory %p [elemsize: %d]\n", (
void*)chkmem, chkmem->elemsize);
1628 assert(chkmem !=
NULL);
1630 return ((
long long)(chkmem->elemsize) * (
long long)(chkmem->storesize));
1656 long long tmpmemalloc = 0LL;
1657 long long tmpmemused = 0LL;
1660 assert(blkmem !=
NULL);
1661 assert(blkmem->chkmemhash !=
NULL);
1665 chkmem = blkmem->chkmemhash[i];
1666 while( chkmem !=
NULL )
1669 tmpmemalloc += ((chkmem->elemsize * chkmem->storesize) + chkmem->nchunks *
sizeof(
CHUNK) +
sizeof(
BMS_CHKMEM));
1670 tmpmemused += (chkmem->elemsize * (chkmem->storesize - chkmem->eagerfreesize - chkmem->lazyfreesize));
1671 chkmem = chkmem->nextchkmem;
1674 assert(tmpmemalloc == blkmem->memallocated);
1675 assert(tmpmemused == blkmem->memused);
1678 #define checkBlkmem(blkmem) 1696 assert(blkmem !=
NULL);
1701 chkmem = blkmem->chkmemhash[i];
1703 chkmem = chkmem->nextchkmem;
1718 return (
int) (((uint32_t)size * UINT32_C(0x9e3779b9))>>(32-
CHKHASH_POWER));
1726 const char* filename,
1734 if( blkmem !=
NULL )
1737 blkmem->chkmemhash[i] =
NULL;
1738 blkmem->initchunksize = initchunksize;
1739 blkmem->garbagefactor = garbagefactor;
1740 blkmem->memused = 0;
1741 blkmem->memallocated = 0;
1742 blkmem->maxmemused = 0;
1743 blkmem->maxmemunused = 0;
1744 blkmem->maxmemallocated = 0;
1749 printError(
"Insufficient memory for block memory header.\n");
1758 const char* filename,
1766 if( blkmem !=
NULL )
1770 chkmem = blkmem->chkmemhash[i];
1771 while( chkmem !=
NULL )
1773 nextchkmem = chkmem->nextchkmem;
1775 chkmem = nextchkmem;
1777 blkmem->chkmemhash[i] =
NULL;
1779 blkmem->memused = 0;
1780 assert(blkmem->memallocated == 0);
1785 printError(
"Tried to clear null block memory.\n");
1792 const char* filename,
1796 assert(blkmem !=
NULL);
1798 if( *blkmem !=
NULL )
1802 assert(*blkmem ==
NULL);
1807 printError(
"Tried to destroy null block memory.\n");
1816 const char* filename,
1824 assert( blkmem !=
NULL );
1831 chkmemptr = &(blkmem->chkmemhash[hashnumber]);
1832 while( *chkmemptr !=
NULL && (*chkmemptr)->elemsize != (
int)size )
1833 chkmemptr = &((*chkmemptr)->nextchkmem);
1836 if( *chkmemptr ==
NULL )
1838 *chkmemptr =
createChkmem((
int)size, blkmem->initchunksize, blkmem->garbagefactor, &blkmem->memallocated);
1839 if( *chkmemptr ==
NULL )
1842 printError(
"Insufficient memory for chunk block.\n");
1847 (*chkmemptr)->line = line;
1857 printError(
"Insufficient memory for new chunk.\n");
1859 debugMessage(
"alloced %8llu bytes in %p [%s:%d]\n", (
unsigned long long)size, ptr, filename, line);
1862 blkmem->memused += (
long long) size;
1863 blkmem->maxmemused =
MAX(blkmem->maxmemused, blkmem->memused);
1864 blkmem->maxmemunused =
MAX(blkmem->maxmemunused, blkmem->memallocated - blkmem->memused);
1865 blkmem->maxmemallocated =
MAX(blkmem->maxmemallocated, blkmem->memallocated);
1867 assert(blkmem->memused >= 0);
1868 assert(blkmem->memallocated >= 0);
1879 const char* filename,
1900 const char* filename,
1921 const char* filename,
1940 const char* filename,
1948 assert(oldsize == 0);
1961 alignSize(&oldsize);
1962 alignSize(&newsize);
1963 if( oldsize == newsize )
1967 if( newptr !=
NULL )
1981 const char* filename,
1989 assert(oldnum == 0);
2002 if ( oldnum == newnum )
2006 if ( newptr !=
NULL )
2018 const char* filename,
2024 assert(source !=
NULL);
2039 const char* filename,
2045 assert(source !=
NULL);
2060 const char* filename,
2067 assert(ptr !=
NULL);
2068 assert(*ptr !=
NULL);
2074 debugMessage(
"free %8llu bytes in %p [%s:%d]\n", (
unsigned long long)size, *ptr, filename, line);
2077 assert( blkmem->chkmemhash !=
NULL );
2078 chkmem = blkmem->chkmemhash[hashnumber];
2079 while( chkmem !=
NULL && chkmem->elemsize != (
int)size )
2080 chkmem = chkmem->nextchkmem;
2081 if( chkmem ==
NULL )
2084 printError(
"Tried to free pointer <%p> in block memory <%p> of unknown size %llu.\n", *ptr, (
void*)blkmem, (
unsigned long long)size);
2087 assert(chkmem->elemsize == (
int)size);
2091 blkmem->memused -= (
long long) size;
2093 blkmem->maxmemunused =
MAX(blkmem->maxmemunused, blkmem->memallocated - blkmem->memused);
2095 assert(blkmem->memused >= 0);
2096 assert(blkmem->memallocated >= 0);
2108 const char* filename,
2112 assert( blkmem !=
NULL );
2113 assert( ptr !=
NULL );
2117 else if( size != 0 )
2120 printError(
"Tried to free null block pointer.\n");
2130 const char* filename,
2134 assert( blkmem !=
NULL );
2135 assert( ptr !=
NULL );
2153 assert(blkmem !=
NULL);
2159 chkmemptr = &blkmem->chkmemhash[i];
2160 while( *chkmemptr !=
NULL )
2164 if( (*chkmemptr)->nchunks == 0 )
2168 assert((*chkmemptr)->lazyfreesize == 0);
2169 nextchkmem = (*chkmemptr)->nextchkmem;
2171 *chkmemptr = nextchkmem;
2175 chkmemptr = &(*chkmemptr)->nextchkmem;
2185 assert( blkmem !=
NULL );
2187 return blkmem->memallocated;
2195 assert( blkmem !=
NULL );
2197 return blkmem->memused;
2205 assert( blkmem !=
NULL );
2207 return blkmem->memallocated - blkmem->memused;
2215 assert( blkmem !=
NULL );
2217 return blkmem->maxmemused;
2225 assert( blkmem !=
NULL );
2227 return blkmem->maxmemunused;
2235 assert( blkmem !=
NULL );
2237 return blkmem->maxmemallocated;
2248 assert(blkmem !=
NULL);
2254 if( chkmem ==
NULL )
2257 return (
size_t)(chkmem->elemsize);
2267 int nunusedblocks = 0;
2268 int totalnchunks = 0;
2269 int totalneagerchunks = 0;
2270 int totalnelems = 0;
2271 int totalneagerelems = 0;
2272 int totalnlazyelems = 0;
2274 int totalngarbagecalls = 0;
2275 int totalngarbagefrees = 0;
2277 long long allocedmem = 0;
2278 long long freemem = 0;
2282 printInfo(
" ElSize #Chunk #Eag #Elems #EagFr #LazFr #GCl #GFr Free MBytes First Allocator\n");
2284 printInfo(
" ElSize #Chunk #Eag #Elems #EagFr #LazFr Free MBytes\n");
2287 assert(blkmem !=
NULL);
2291 chkmem = blkmem->chkmemhash[i];
2292 while( chkmem !=
NULL )
2296 int neagerchunks = 0;
2297 int neagerelems = 0;
2301 assert(chunk != NULL);
2302 assert(chunk->elemsize == chkmem->elemsize);
2303 assert(chunk->chkmem == chkmem);
2305 nelems += chunk->storesize;
2306 if( chunk->eagerfree != NULL )
2309 neagerelems += chunk->eagerfreesize;
2313 assert(nchunks == chkmem->nchunks);
2314 assert(nelems == chkmem->storesize);
2315 assert(neagerelems == chkmem->eagerfreesize);
2320 allocedmem += (
long long)chkmem->elemsize * (
long long)nelems;
2321 freemem += (
long long)chkmem->elemsize * ((
long long)neagerelems + (
long long)chkmem->lazyfreesize);
2324 printInfo(
"%7d %6d %4d %7d %7d %7d %5d %4d %5.1f%% %6.1f %s:%d\n",
2325 chkmem->elemsize, nchunks, neagerchunks, nelems,
2326 neagerelems, chkmem->lazyfreesize, chkmem->ngarbagecalls, chkmem->ngarbagefrees,
2327 100.0 * (
double) (neagerelems + chkmem->lazyfreesize) / (
double) (nelems),
2328 (
double)chkmem->elemsize * nelems / (1024.0*1024.0),
2329 chkmem->filename, chkmem->line);
2331 printInfo(
"%7d %6d %4d %7d %7d %7d %5.1f%% %6.1f\n",
2332 chkmem->elemsize, nchunks, neagerchunks, nelems,
2333 neagerelems, chkmem->lazyfreesize,
2334 100.0 * (
double) (neagerelems + chkmem->lazyfreesize) / (
double) (nelems),
2335 (
double)chkmem->elemsize * nelems / (1024.0*1024.0));
2341 printInfo(
"%7d <unused> %5d %4d %s:%d\n",
2342 chkmem->elemsize, chkmem->ngarbagecalls, chkmem->ngarbagefrees,
2343 chkmem->filename, chkmem->line);
2345 printInfo(
"%7d <unused>\n", chkmem->elemsize);
2349 totalnchunks += nchunks;
2350 totalneagerchunks += neagerchunks;
2351 totalnelems += nelems;
2352 totalneagerelems += neagerelems;
2353 totalnlazyelems += chkmem->lazyfreesize;
2355 totalngarbagecalls += chkmem->ngarbagecalls;
2356 totalngarbagefrees += chkmem->ngarbagefrees;
2358 chkmem = chkmem->nextchkmem;
2362 printInfo(
" Total %6d %4d %7d %7d %7d %5d %4d %5.1f%% %6.1f\n",
2363 totalnchunks, totalneagerchunks, totalnelems, totalneagerelems, totalnlazyelems,
2364 totalngarbagecalls, totalngarbagefrees,
2365 totalnelems > 0 ? 100.0 * (
double) (totalneagerelems + totalnlazyelems) / (
double) (totalnelems) : 0.0,
2366 (
double)allocedmem/(1024.0*1024.0));
2368 printInfo(
" Total %6d %4d %7d %7d %7d %5.1f%% %6.1f\n",
2369 totalnchunks, totalneagerchunks, totalnelems, totalneagerelems, totalnlazyelems,
2370 totalnelems > 0 ? 100.0 * (
double) (totalneagerelems + totalnlazyelems) / (
double) (totalnelems) : 0.0,
2371 (
double)allocedmem/(1024.0*1024.0));
2374 nblocks + nunusedblocks, nunusedblocks, allocedmem, freemem);
2375 if( allocedmem > 0 )
2376 printInfo(
" (%.1f%%)", 100.0 * (
double) freemem / (
double) allocedmem);
2379 printInfo(
"Memory Peaks: Used Lazy Total\n");
2380 printInfo(
" %6.1f %6.1f %6.1f MBytes\n", (
double)blkmem->maxmemused / (1024.0 * 1024.0),
2381 (
double)blkmem->maxmemunused / (1024.0 * 1024.0), (
double)blkmem->maxmemallocated / (1024.0 * 1024.0));
2390 long long allocedmem = 0;
2391 long long freemem = 0;
2394 assert(blkmem !=
NULL);
2398 chkmem = blkmem->chkmemhash[i];
2399 while( chkmem !=
NULL )
2403 int neagerelems = 0;
2407 assert(chunk != NULL);
2408 assert(chunk->elemsize == chkmem->elemsize);
2409 assert(chunk->chkmem == chkmem);
2411 nelems += chunk->storesize;
2412 if( chunk->eagerfree != NULL )
2413 neagerelems += chunk->eagerfreesize;
2416 assert(nchunks == chkmem->nchunks);
2417 assert(nelems == chkmem->storesize);
2418 assert(neagerelems == chkmem->eagerfreesize);
2422 allocedmem += (
long long)chkmem->elemsize * (
long long)nelems;
2423 freemem += (
long long)chkmem->elemsize * ((
long long)neagerelems + (
long long)chkmem->lazyfreesize);
2425 if( nelems != neagerelems + chkmem->lazyfreesize )
2429 (((
long long)nelems - (
long long)neagerelems) - (
long long)chkmem->lazyfreesize)
2430 * (
long long)(chkmem->elemsize),
2431 (nelems - neagerelems) - chkmem->lazyfreesize, (
long long)(chkmem->elemsize),
2432 chkmem->filename, chkmem->line);
2434 errorMessage(
"%" LONGINT_FORMAT
" bytes (%d elements of size %" LONGINT_FORMAT
") not freed.\n",
2435 ((nelems - neagerelems) - chkmem->lazyfreesize) * (
long long)(chkmem->elemsize),
2436 (nelems - neagerelems) - chkmem->lazyfreesize, (
long long)(chkmem->elemsize));
2440 chkmem = chkmem->nextchkmem;
2444 if( allocedmem != freemem )
2449 return allocedmem - freemem;
2480 double arraygrowfac,
2483 const char* filename,
2489 assert( arraygrowinit > 0 );
2490 assert( arraygrowfac > 0.0 );
2493 if ( buffer !=
NULL )
2499 buffer->
clean = clean;
2508 printError(
"Insufficient memory for buffer memory header.\n");
2517 const char* filename,
2523 if ( *buffer !=
NULL )
2525 i = (*buffer)->ndata;
2529 assert( ! (*buffer)->used[i] );
2543 printError(
"Tried to free null buffer memory.\n");
2553 assert( buffer !=
NULL );
2554 assert( arraygrowfac > 0.0 );
2565 assert( buffer !=
NULL );
2566 assert( arraygrowinit > 0 );
2571 #ifndef SCIP_NOBUFFERMEM 2585 assert( growfac >= 1.0 );
2587 if ( growfac == 1.0 )
2588 size =
MAX(initsize, num);
2594 initsize =
MAX(initsize, 4);
2599 while ( size < num && size > oldsize )
2602 size = (size_t)(growfac * size + initsize);
2606 if ( size <= oldsize )
2610 assert( size >= initsize );
2611 assert( size >= num );
2622 const char* filename,
2628 #ifndef SCIP_NOBUFFERMEM 2632 #ifndef SCIP_NOBUFFERMEM 2633 assert( buffer !=
NULL );
2652 printError(
"Insufficient memory for reallocating buffer data storage.\n");
2659 printError(
"Insufficient memory for reallocating buffer size storage.\n");
2666 printError(
"Insufficient memory for reallocating buffer used storage.\n");
2671 for (i = buffer->
ndata; i < newsize; ++i)
2674 buffer->
size[i] = 0;
2677 buffer->
ndata = newsize;
2683 assert( ! buffer->
used[bufnum] );
2684 if ( buffer->
size[bufnum] < size )
2695 char* tmpptr = (
char*)(buffer->
data[bufnum]);
2696 size_t inc = buffer->
size[bufnum] /
sizeof(*tmpptr);
2701 assert( newsize > buffer->
size[bufnum] );
2703 buffer->
size[bufnum] = newsize;
2705 if ( buffer->
data[bufnum] ==
NULL )
2708 printError(
"Insufficient memory for reallocating buffer storage.\n");
2712 assert( buffer->
size[bufnum] >= size );
2718 char* tmpptr = (
char*)(buffer->
data[bufnum]);
2719 unsigned int inc = buffer->
size[bufnum] /
sizeof(*tmpptr);
2722 while( --tmpptr >= (
char*)(buffer->
data[bufnum]) )
2723 assert(*tmpptr ==
'\0');
2727 ptr = buffer->
data[bufnum];
2731 debugMessage(
"Allocated buffer %llu/%llu at %p of size %llu (required size: %llu) for pointer %p.\n",
2732 (
unsigned long long)bufnum, (
unsigned long long)(buffer->
ndata), buffer->
data[bufnum],
2733 (
unsigned long long)(buffer->
size[bufnum]), (
unsigned long long)size, ptr);
2756 const char* filename,
2777 const char* filename,
2798 const char* filename,
2817 const char* filename,
2822 #ifndef SCIP_NOBUFFERMEM 2826 #ifndef SCIP_NOBUFFERMEM 2827 assert( buffer !=
NULL );
2829 assert(!buffer->
clean);
2842 while ( bufnum > 0 && buffer->
data[bufnum] != ptr )
2846 assert( buffer->
data[bufnum] == newptr );
2847 assert( buffer->
used[bufnum] );
2848 assert( buffer->
size[bufnum] >= 1 );
2851 if ( size > buffer->
size[bufnum] )
2858 assert( newsize > buffer->
size[bufnum] );
2860 buffer->
size[bufnum] = newsize;
2861 if ( buffer->
data[bufnum] ==
NULL )
2864 printError(
"Insufficient memory for reallocating buffer storage.\n");
2867 newptr = buffer->
data[bufnum];
2869 assert( buffer->
size[bufnum] >= size );
2870 assert( newptr == buffer->
data[bufnum] );
2872 debugMessage(
"Reallocated buffer %llu/%llu at %p to size %llu (required size: %llu) for pointer %p.\n",
2873 (
unsigned long long)bufnum, (
unsigned long long)(buffer->
ndata), buffer->
data[bufnum],
2874 (
unsigned long long)(buffer->
size[bufnum]), (
unsigned long long)size, newptr);
2889 const char* filename,
2911 const char* filename,
2932 const char* filename,
2938 assert( source !=
NULL );
2956 const char* filename,
2962 assert( source !=
NULL );
2979 const char* filename,
2985 assert( buffer !=
NULL );
2988 assert( ptr !=
NULL );
2989 assert( *ptr !=
NULL );
2996 while ( bufnum > 0 && buffer->
data[bufnum] != *ptr )
2999 #ifdef CHECKBUFFERORDER 3000 if ( bufnum < buffer->firstfree - 1 )
3002 warningMessage(
"[%s:%d]: freeing buffer in wrong order.\n", filename, line);
3007 if ( bufnum == 0 && buffer->
data[bufnum] != *ptr )
3010 printError(
"Tried to free unkown buffer pointer.\n");
3013 if ( ! buffer->
used[bufnum] )
3016 printError(
"Tried to free buffer pointer already freed.\n");
3026 uint8_t* tmpptr = (uint8_t*)(buffer->
data[bufnum]);
3028 for( i = 0; i < buffer->
size[bufnum]; ++i )
3029 assert(tmpptr[i] == 0);
3033 assert( buffer->
data[bufnum] == *ptr );
3039 debugMessage(
"Freed buffer %llu/%llu at %p of size %llu for pointer %p, first free is %llu.\n",
3040 (
unsigned long long)bufnum, (
unsigned long long)(buffer->
ndata), buffer->
data[bufnum],
3041 (
unsigned long long)(buffer->
size[bufnum]), *ptr, (
unsigned long long)(buffer->
firstfree));
3050 const char* filename,
3054 assert( ptr !=
NULL );
3056 #ifndef SCIP_NOBUFFERMEM 3062 printError(
"Tried to free null buffer pointer.\n");
3073 const char* filename,
3077 assert( ptr !=
NULL );
3081 #ifndef SCIP_NOBUFFERMEM 3094 assert( buffer !=
NULL );
3105 size_t totalmem = 0UL;
3108 assert( buffer !=
NULL );
3109 for (i = 0; i < buffer->
ndata; ++i)
3110 totalmem += buffer->
size[i];
3111 assert( totalmem == buffer->
totalmem );
3114 return (
long long) buffer->
totalmem;
3125 assert( buffer !=
NULL );
3128 for (i = 0; i < buffer->
ndata; ++i)
3130 printf(
"[%c] %8llu bytes at %p\n", buffer->
used[i] ?
'*' :
' ', (
unsigned long long)(buffer->
size[i]), buffer->
data[i]);
3131 totalmem += buffer->
size[i];
3133 printf(
" %8llu bytes total in %llu buffers\n", (
unsigned long long)totalmem, (
unsigned long long)(buffer->
ndata));
void BMSdestroyBlockMemory_call(BMS_BLKMEM **blkmem, const char *filename, int line)
long long BMSgetMemoryUsed_call(void)
void * BMSallocChunkMemory_call(BMS_CHKMEM *chkmem, size_t size, const char *filename, int line)
#define BMScopyMemorySize(ptr, source, size)
struct BMS_ChkMem BMS_CHKMEM
int BMSisAligned(size_t size)
static INLINE void BMSfreeBlockMemory_work(BMS_BLKMEM *blkmem, void **ptr, size_t size, const char *filename, int line)
#define BMSfreeMemoryArrayNull(ptr)
#define SCIP_RBTREE_HOOKS
void * BMSduplicateMemoryArray_call(const void *source, size_t num, size_t typesize, const char *filename, int line)
void BMSdisplayBlockMemory_call(const BMS_BLKMEM *blkmem)
void * BMSallocBlockMemoryArray_call(BMS_BLKMEM *blkmem, size_t num, size_t typesize, const char *filename, int line)
#define checkChunk(chunk)
static void freeChkmemElement(BMS_CHKMEM *chkmem, void *ptr, long long *memsize, const char *filename, int line)
void BMSfreeBufferMemoryNull_call(BMS_BUFMEM *buffer, void **ptr, const char *filename, int line)
void * BMSduplicateBufferMemoryArray_call(BMS_BUFMEM *buffer, const void *source, size_t num, size_t typesize, const char *filename, int line)
#define checkBlkmem(blkmem)
void * BMSallocBufferMemoryArray_call(BMS_BUFMEM *buffer, size_t num, size_t typesize, const char *filename, int line)
void * BMSduplicateChunkMemory_call(BMS_CHKMEM *chkmem, const void *source, size_t size, const char *filename, int line)
void * BMSallocClearBlockMemoryArray_call(BMS_BLKMEM *blkmem, size_t num, size_t typesize, const char *filename, int line)
void BMSdestroyChunkMemory_call(BMS_CHKMEM **chkmem, const char *filename, int line)
void * BMSallocBlockMemory_call(BMS_BLKMEM *blkmem, size_t size, const char *filename, int line)
size_t BMSgetBlockPointerSize_call(const BMS_BLKMEM *blkmem, const void *ptr)
long long BMScheckEmptyBlockMemory_call(const BMS_BLKMEM *blkmem)
void BMSfreeChunkMemory_call(BMS_CHKMEM *chkmem, void **ptr, size_t size, const char *filename, int line)
static void * allocChunkElement(CHUNK *chunk)
static void * allocChkmemElement(BMS_CHKMEM *chkmem, long long *memsize)
static SCIP_DEF_RBTREE_FIND(rbTreeFindChunk, const void *, CHUNK, CHUNK_LT, CHUNK_GT)
#define SCIPrbtreeDelete(root, node)
static void unlinkEagerChunk(CHUNK *chunk)
void * BMSreallocBlockMemoryArray_call(BMS_BLKMEM *blkmem, void *ptr, size_t oldnum, size_t newnum, size_t typesize, const char *filename, int line)
#define FOR_EACH_NODE(type, n, r, body)
void * BMSreallocBlockMemory_call(BMS_BLKMEM *blkmem, void *ptr, size_t oldsize, size_t newsize, const char *filename, int line)
#define printErrorHeader(f, l)
#define BMSfreeMemory(ptr)
static BMS_CHKMEM * findChkmem(const BMS_BLKMEM *blkmem, const void *ptr)
static int linkChunk(BMS_CHKMEM *chkmem, CHUNK *chunk)
void * BMSallocClearBufferMemoryArray_call(BMS_BUFMEM *buffer, size_t num, size_t typesize, const char *filename, int line)
long long BMSgetBufferMemoryUsed(const BMS_BUFMEM *buffer)
void BMSsetBufferMemoryArraygrowinit(BMS_BUFMEM *buffer, int arraygrowinit)
static void freeChunk(CHUNK *chunk, long long *memsize)
long long BMSgetBlockMemoryUsedMax_call(const BMS_BLKMEM *blkmem)
void * BMSreallocMemoryArray_call(void *ptr, size_t num, size_t typesize, const char *filename, int line)
static void clearChkmem(BMS_CHKMEM *chkmem, long long *memsize)
static INLINE void * BMSallocBufferMemory_work(BMS_BUFMEM *buffer, size_t size, const char *filename, int line)
static INLINE void BMSfreeBufferMemory_work(BMS_BUFMEM *buffer, void **ptr, const char *filename, int line)
long long BMSgetBlockMemoryAllocated_call(const BMS_BLKMEM *blkmem)
void * BMSallocBufferMemory_call(BMS_BUFMEM *buffer, size_t size, const char *filename, int line)
static void unlinkChunk(CHUNK *chunk)
#define addMemlistEntry(ptr, size, filename, line)
static INLINE void * BMSallocBlockMemory_work(BMS_BLKMEM *blkmem, size_t size, const char *filename, int line)
void BMSgarbagecollectBlockMemory_call(BMS_BLKMEM *blkmem)
void * BMSduplicateMemory_call(const void *source, size_t size, const char *filename, int line)
long long BMSgetBlockMemoryUsed_call(const BMS_BLKMEM *blkmem)
void * BMSallocMemoryArray_call(size_t num, size_t typesize, const char *filename, int line)
long long BMSgetBlockMemoryAllocatedMax_call(const BMS_BLKMEM *blkmem)
static int isPtrInChunk(const CHUNK *chunk, const void *ptr)
void BMSdestroyBufferMemory_call(BMS_BUFMEM **buffer, const char *filename, int line)
void * BMSduplicateBlockMemoryArray_call(BMS_BLKMEM *blkmem, const void *source, size_t num, size_t typesize, const char *filename, int line)
#define BMSduplicateMemoryArray(ptr, source, num)
static int isPtrInChkmem(const BMS_CHKMEM *chkmem, const void *ptr)
void BMSgarbagecollectChunkMemory_call(BMS_CHKMEM *chkmem)
#define checkChkmem(chkmem)
void BMSsetBufferMemoryArraygrowfac(BMS_BUFMEM *buffer, double arraygrowfac)
void BMSclearMemory_call(void *ptr, size_t size)
long long BMSgetChunkMemoryUsed_call(const BMS_CHKMEM *chkmem)
static void freeChunkElement(CHUNK *chunk, void *ptr)
void BMSdisplayMemory_call(void)
void BMSfreeMemory_call(void **ptr, const char *filename, int line)
static int getHashNumber(int size)
#define CHUNK_LT(ptr, chunk)
void BMScopyMemory_call(void *ptr, const void *source, size_t size)
unsigned int arraygrowinit
BMS_BUFMEM * BMScreateBufferMemory_call(double arraygrowfac, int arraygrowinit, unsigned int clean, const char *filename, int line)
void BMSfreeBufferMemory_call(BMS_BUFMEM *buffer, void **ptr, const char *filename, int line)
void BMSfreeBlockMemory_call(BMS_BLKMEM *blkmem, void **ptr, size_t size, const char *filename, int line)
static void garbagecollectChkmem(BMS_CHKMEM *chkmem, long long *memsize)
BMS_BLKMEM * BMScreateBlockMemory_call(int initchunksize, int garbagefactor, const char *filename, int line)
static void linkEagerChunk(BMS_CHKMEM *chkmem, CHUNK *chunk)
void BMSmoveMemory_call(void *ptr, const void *source, size_t size)
void * BMSreallocBufferMemoryArray_call(BMS_BUFMEM *buffer, void *ptr, size_t num, size_t typesize, const char *filename, int line)
#define BMSclearMemorySize(ptr, size)
void BMSprintBufferMemory(BMS_BUFMEM *buffer)
void * BMSduplicateBlockMemory_call(BMS_BLKMEM *blkmem, const void *source, size_t size, const char *filename, int line)
static void destroyChkmem(BMS_CHKMEM **chkmem, long long *memsize)
long long BMSgetBlockMemoryUnused_call(const BMS_BLKMEM *blkmem)
void * BMSallocClearMemory_call(size_t num, size_t typesize, const char *filename, int line)
void BMScheckEmptyMemory_call(void)
void BMSclearChunkMemory_call(BMS_CHKMEM *chkmem, const char *filename, int line)
size_t BMSgetNUsedBufferMemory(BMS_BUFMEM *buffer)
size_t BMSgetPointerSize_call(const void *ptr)
void * BMSreallocMemory_call(void *ptr, size_t size, const char *filename, int line)
void * BMSduplicateBufferMemory_call(BMS_BUFMEM *buffer, const void *source, size_t size, const char *filename, int line)
#define BMSallocMemorySize(ptr, size)
public methods for message output
#define BMSreallocMemorySize(ptr, size)
#define removeMemlistEntry(ptr, filename, line)
static int createChunk(BMS_CHKMEM *chkmem, long long *memsize)
void * BMSallocMemory_call(size_t size, const char *filename, int line)
#define SCIPrbtreeInsert(r, p, c, n)
void BMSfreeBlockMemoryNull_call(BMS_BLKMEM *blkmem, void **ptr, size_t size, const char *filename, int line)
#define BMSallocClearMemorySize(ptr, size)
#define BMSallocMemory(ptr)
#define BMSreallocMemoryArray(ptr, num)
static CHUNK * findChunk(const BMS_CHKMEM *chkmem, const void *ptr)
static INLINE void * BMSreallocBufferMemory_work(BMS_BUFMEM *buffer, void *ptr, size_t size, const char *filename, int line)
static void destroyChunk(CHUNK *chunk, long long *memsize)
intrusive red black tree datastructure
BMS_CHKMEM * BMScreateChunkMemory_call(size_t size, int initchunksize, int garbagefactor, const char *filename, int line)
void BMSfreeMemoryNull_call(void **ptr, const char *filename, int line)
long long BMSgetBlockMemoryUnusedMax_call(const BMS_BLKMEM *blkmem)
static BMS_CHKMEM * createChkmem(int size, int initchunksize, int garbagefactor, long long *memsize)
void BMSfreeChunkMemoryNull_call(BMS_CHKMEM *chkmem, void **ptr, size_t size, const char *filename, int line)
static size_t calcMemoryGrowSize(size_t initsize, SCIP_Real growfac, size_t num)
common defines and data types used in all packages of SCIP
#define CHUNK_GT(ptr, chunk)
struct BMS_BlkMem BMS_BLKMEM
void * BMSreallocBufferMemory_call(BMS_BUFMEM *buffer, void *ptr, size_t size, const char *filename, int line)
void BMSclearBlockMemory_call(BMS_BLKMEM *blkmem, const char *filename, int line)
void BMSalignMemsize(size_t *size)
memory allocation routines