37 #define __STDC_LIMIT_MACROS 48 #ifndef NO_CONFIG_HEADER 49 #include "scip/config.h" 67 #ifndef SCIP_THREADSAFE 71 #ifdef ENABLE_MEMLIST_CHECKS 87 #ifdef SCIPdebugMessage 88 #define debugMessage SCIPdebugMessage 89 #define errorMessage SCIPerrorMessage 91 #define debugMessage while( FALSE ) printf 92 #define errorMessage printf 93 #define printErrorHeader(f,l) printf("[%s:%d] ERROR: ", f, l) 94 #define printError printf 97 #ifdef ENABLE_MEMLIST_CHECKS 98 #define warningMessage printf 100 #define printInfo printf 108 #define MAX(x,y) ((x) >= (y) ? (x) : (y)) 109 #define MIN(x,y) ((x) <= (y) ? (x) : (y)) 112 #ifndef SCIP_LONGINT_FORMAT 113 #if defined(_WIN32) || defined(_WIN64) 114 #define LONGINT_FORMAT "I64d" 116 #define LONGINT_FORMAT "lld" 119 #define LONGINT_FORMAT SCIP_LONGINT_FORMAT 122 #ifndef SCIP_MAXMEMSIZE 124 #define MAXMEMSIZE SIZE_MAX / 2 126 #define MAXMEMSIZE SCIP_MAXMEMSIZE 131 #if defined(_WIN32) || defined(_WIN64) || defined(__STDC__) 132 #define INLINE __inline 134 #define INLINE inline 145 #if !defined(NDEBUG) && defined(ENABLE_MEMLIST_CHECKS) 147 typedef struct Memlist MEMLIST;
159 static MEMLIST* memlist =
NULL;
160 static size_t memused = 0;
169 MEMLIST* list = memlist;
172 while( list !=
NULL )
177 assert(used == memused);
180 #define checkMemlist() 188 const char* filename,
194 assert(ptr !=
NULL && size > 0);
196 list = (MEMLIST*)malloc(
sizeof(MEMLIST));
197 assert(list !=
NULL);
201 list->filename = strdup(filename);
202 assert(list->filename !=
NULL);
204 list->next = memlist;
214 const char* filename,
225 while( list !=
NULL && ptr != list->ptr )
227 listptr = &(list->next);
232 assert(ptr == list->ptr);
234 *listptr = list->next;
235 assert( list->size <= memused );
236 memused -= list->size;
237 free(list->filename);
243 printError(
"Tried to free unknown pointer <%p>.\n", ptr);
256 while( list !=
NULL && ptr != list->ptr )
274 while( list !=
NULL )
276 printInfo(
"%12p %8llu %s:%d\n", list->ptr, (
unsigned long long) list->size, list->filename, list->line);
280 printInfo(
"Total: %8llu\n", (
unsigned long long) memused);
281 if( used != memused )
283 errorMessage(
"Used memory in list sums up to %llu instead of %llu\n", (
unsigned long long)used, (
unsigned long long)memused);
293 if( memlist !=
NULL || memused > 0 )
295 warningMessage(
"Memory list not empty.\n");
305 return (
long long) memused;
310 #define addMemlistEntry(ptr, size, filename, line) do { (void) (ptr); (void) (size); (void) (filename); (void) (line); } while(0) 311 #define removeMemlistEntry(ptr, filename, line) do { (void) (ptr); (void) (filename); (void) (line); } while(0) 331 printInfo(
"Optimized, threadsafe version of memory shell linked - no memory diagnostics available.\n");
355 const char* filename,
361 assert(typesize > 0);
363 debugMessage(
"calloc %llu elements of %llu bytes [%s:%d]\n", (
unsigned long long)num, (
unsigned long long)typesize,
376 typesize =
MAX(typesize, 1);
377 ptr = calloc(num, typesize);
382 printError(
"Insufficient memory for allocation of %llu bytes.\n", (
unsigned long long)(num) * (typesize));
393 const char* filename,
399 debugMessage(
"malloc %llu bytes [%s:%d]\n", (
unsigned long long)size, filename, line);
416 printError(
"Insufficient memory for allocation of %llu bytes.\n", (
unsigned long long)size);
428 const char* filename,
435 debugMessage(
"malloc %llu elements of %llu bytes [%s:%d]\n",
436 (
unsigned long long)num, (
unsigned long long)typesize, filename, line);
447 size = num * typesize;
454 printError(
"Insufficient memory for allocation of %llu bytes.\n", (
unsigned long long)size);
466 const char* filename,
485 newptr = realloc(ptr, size);
490 printError(
"Insufficient memory for reallocation of %llu bytes.\n", (
unsigned long long)size);
503 const char* filename,
522 size = num * typesize;
524 newptr = realloc(ptr, size);
529 printError(
"Insufficient memory for reallocation of %llu bytes.\n", (
unsigned long long)size);
546 memset(ptr, 0, size);
560 assert(source !=
NULL);
561 memcpy(ptr, source, size);
577 assert(source !=
NULL);
578 memmove(ptr, source, size);
586 const char* filename,
592 assert(source !=
NULL || size == 0);
606 const char* filename,
612 assert(source !=
NULL || num == 0);
624 const char* filename,
628 assert( ptr !=
NULL );
646 const char* filename,
650 assert( ptr !=
NULL );
667 #define CHKHASH_POWER 10 668 #define CHKHASH_SIZE (1<<CHKHASH_POWER) 675 long long memallocated;
676 long long maxmemused;
677 long long maxmemunused;
678 long long maxmemallocated;
695 #define CHUNKLENGTH_MIN 1024 696 #define CHUNKLENGTH_MAX 1048576 697 #define STORESIZE_MAX 8192 698 #define GARBAGE_SIZE 256 699 #define ALIGNMENT (sizeof(FREELIST)) 750 #define CHUNK_LT(ptr,chunk) ptr < chunk->store 751 #define CHUNK_GT(ptr,chunk) ptr >= chunk->storeend 795 assert(chunk !=
NULL);
796 assert(chunk->store <= chunk->storeend);
798 return (ptr >= (
void*)(chunk->store) && ptr < (
void*)(chunk->storeend));
814 assert(chkmem !=
NULL);
817 if( rbTreeFindChunk(chkmem->rootchunk, ptr, &chunk) == 0 )
831 assert(chkmem !=
NULL);
852 assert(chunk !=
NULL);
853 assert(chunk->store !=
NULL);
854 assert(chunk->storeend == (
void*)((
char*)(chunk->store) + chunk->elemsize * chunk->storesize));
855 assert(chunk->chkmem !=
NULL);
856 assert(chunk->chkmem->elemsize == chunk->elemsize);
858 if( chunk->eagerfree ==
NULL )
859 assert(chunk->nexteager ==
NULL && chunk->preveager ==
NULL);
860 else if( chunk->preveager ==
NULL )
861 assert(chunk->chkmem->firsteager == chunk);
863 if( chunk->nexteager !=
NULL )
864 assert(chunk->nexteager->preveager == chunk);
865 if( chunk->preveager !=
NULL )
866 assert(chunk->preveager->nexteager == chunk);
869 eager = chunk->eagerfree;
870 while( eager !=
NULL )
876 assert(chunk->eagerfreesize == eagerfreesize);
891 assert(chkmem !=
NULL);
902 storesize += chunk->storesize;
903 eagerfreesize += chunk->eagerfreesize;
906 assert(chkmem->nchunks == nchunks);
907 assert(chkmem->storesize == storesize);
908 assert(chkmem->eagerfreesize == eagerfreesize);
910 assert(((
unsigned int) (chkmem->eagerfreesize == 0)) ^ ( (
unsigned int) (chkmem->firsteager !=
NULL)));
912 if( chkmem->firsteager !=
NULL )
913 assert(chkmem->firsteager->preveager ==
NULL);
915 lazy = chkmem->lazyfree;
916 while( lazy !=
NULL )
919 assert(chunk !=
NULL);
920 assert(chunk->chkmem == chkmem);
924 assert(chkmem->lazyfreesize == lazyfreesize);
927 #define checkChunk(chunk) 928 #define checkChkmem(chkmem) 944 assert(chkmem !=
NULL);
945 assert(chunk !=
NULL);
946 assert(chunk->store !=
NULL);
948 debugMessage(
"linking chunk %p to chunk block %p [elemsize:%d, %d chunks]\n",
949 (
void*)chunk, (
void*)chkmem, chkmem->elemsize, chkmem->nchunks);
951 pos = rbTreeFindChunk(chkmem->rootchunk, chunk->store, &parent);
957 chkmem->storesize += chunk->storesize;
970 assert(chunk !=
NULL);
971 assert(chunk->eagerfree ==
NULL);
972 assert(chunk->nexteager ==
NULL);
973 assert(chunk->preveager ==
NULL);
975 chkmem = chunk->chkmem;
976 assert(chkmem !=
NULL);
977 assert(chkmem->elemsize == chunk->elemsize);
979 debugMessage(
"unlinking chunk %p from chunk block %p [elemsize:%d, %d chunks]\n",
980 (
void*)chunk, (
void*)chkmem, chkmem->elemsize, chkmem->nchunks);
986 chkmem->storesize -= chunk->storesize;
996 assert(chunk->chkmem == chkmem);
997 assert(chunk->nexteager ==
NULL);
998 assert(chunk->preveager ==
NULL);
1000 chunk->nexteager = chkmem->firsteager;
1001 chunk->preveager =
NULL;
1002 if( chkmem->firsteager !=
NULL )
1004 assert(chkmem->firsteager->preveager ==
NULL);
1005 chkmem->firsteager->preveager = chunk;
1007 chkmem->firsteager = chunk;
1016 assert(chunk !=
NULL);
1017 assert(chunk->eagerfreesize == 0 || chunk->eagerfreesize == chunk->storesize);
1019 if( chunk->nexteager !=
NULL )
1020 chunk->nexteager->preveager = chunk->preveager;
1021 if( chunk->preveager !=
NULL )
1022 chunk->preveager->nexteager = chunk->nexteager;
1025 assert(chunk->chkmem->firsteager == chunk);
1026 chunk->chkmem->firsteager = chunk->nexteager;
1028 chunk->nexteager =
NULL;
1029 chunk->preveager =
NULL;
1030 chunk->eagerfree =
NULL;
1048 assert(chkmem !=
NULL);
1050 debugMessage(
"creating new chunk in chunk block %p [elemsize: %d]\n", (
void*)chkmem, chkmem->elemsize);
1053 if( chkmem->nchunks == 0 )
1054 storesize = chkmem->initchunksize;
1056 storesize = 2 * chkmem->lastchunksize;
1057 assert(storesize > 0);
1061 storesize =
MAX(storesize, 1);
1062 chkmem->lastchunksize = storesize;
1066 assert( chkmem->elemsize < INT_MAX / storesize );
1067 assert(
sizeof(
CHUNK) <
MAXMEMSIZE - (
size_t)(storesize * chkmem->elemsize) );
1069 if( newchunk ==
NULL )
1073 newchunk->store = (
void*) ((
char*) newchunk +
sizeof(
CHUNK));
1074 newchunk->storeend = (
void*) ((
char*) newchunk->store + (ptrdiff_t)storesize * chkmem->elemsize);
1075 newchunk->eagerfree =
NULL;
1076 newchunk->nexteager =
NULL;
1077 newchunk->preveager =
NULL;
1078 newchunk->chkmem = chkmem;
1079 newchunk->elemsize = chkmem->elemsize;
1080 newchunk->storesize = storesize;
1081 newchunk->eagerfreesize = 0;
1083 if( memsize !=
NULL )
1084 (*memsize) += ((
long long)((
long long)
sizeof(
CHUNK) + (
long long)storesize * chkmem->elemsize));
1086 debugMessage(
"allocated new chunk %p: %d elements with size %d\n", (
void*)newchunk, newchunk->storesize, newchunk->elemsize);
1091 for( i = 0; i < newchunk->storesize - 1; ++i )
1093 freelist = (
FREELIST*) newchunk->store + (ptrdiff_t)i * chkmem->elemsize / (ptrdiff_t)
sizeof(
FREELIST*);
1094 freelist->next = (
FREELIST*) newchunk->store + ((ptrdiff_t)i + 1) * chkmem->elemsize / (ptrdiff_t)
sizeof(
FREELIST*);
1097 freelist = (
FREELIST*) newchunk->store + ((ptrdiff_t) newchunk->storesize - 1) * chkmem->elemsize / (ptrdiff_t)
sizeof(
FREELIST*);
1098 freelist->next = chkmem->lazyfree;
1099 chkmem->lazyfree = (
FREELIST*) (newchunk->store);
1100 chkmem->lazyfreesize += newchunk->storesize;
1117 assert(chunk !=
NULL);
1118 assert(*chunk !=
NULL);
1122 if( memsize !=
NULL )
1123 (*memsize) -= ((
long long)
sizeof(
CHUNK) + (
long long)(*chunk)->storesize * (*chunk)->elemsize);
1136 assert(chunk !=
NULL);
1137 assert(*chunk !=
NULL);
1138 assert((*chunk)->store !=
NULL);
1139 assert((*chunk)->eagerfree !=
NULL);
1140 assert((*chunk)->chkmem !=
NULL);
1141 assert((*chunk)->chkmem->rootchunk !=
NULL);
1142 assert((*chunk)->chkmem->firsteager !=
NULL);
1143 assert((*chunk)->eagerfreesize == (*chunk)->storesize);
1145 debugMessage(
"freeing chunk %p of chunk block %p [elemsize: %d]\n", (
void*)*chunk, (
void*)(*chunk)->chkmem, (*chunk)->chkmem->elemsize);
1148 (*chunk)->chkmem->eagerfreesize -= (*chunk)->eagerfreesize;
1149 assert((*chunk)->chkmem->eagerfreesize >= 0);
1169 assert(chunk !=
NULL);
1170 assert(chunk->eagerfree !=
NULL);
1171 assert(chunk->eagerfreesize > 0);
1172 assert(chunk->chkmem !=
NULL);
1174 debugMessage(
"allocating chunk element in chunk %p [elemsize: %d]\n", (
void*)chunk, chunk->chkmem->elemsize);
1177 ptr = chunk->eagerfree;
1178 chunk->eagerfree = ptr->next;
1179 chunk->eagerfreesize--;
1180 chunk->chkmem->eagerfreesize--;
1182 assert((chunk->eagerfreesize == 0 && chunk->eagerfree ==
NULL)
1183 || (chunk->eagerfreesize != 0 && chunk->eagerfree !=
NULL));
1184 assert(chunk->chkmem->eagerfreesize >= 0);
1187 if( chunk->eagerfree ==
NULL )
1189 assert(chunk->eagerfreesize == 0);
1205 assert(chunk !=
NULL);
1206 assert(chunk->chkmem !=
NULL);
1209 debugMessage(
"freeing chunk element %p of chunk %p [elemsize: %d]\n", (
void*)ptr, (
void*)chunk, chunk->chkmem->elemsize);
1212 if( chunk->eagerfree ==
NULL )
1214 assert(chunk->eagerfreesize == 0);
1219 ((
FREELIST*)ptr)->next = chunk->eagerfree;
1221 chunk->eagerfreesize++;
1222 chunk->chkmem->eagerfreesize++;
1243 if( chkmem ==
NULL )
1246 chkmem->lazyfree =
NULL;
1247 chkmem->rootchunk =
NULL;
1248 chkmem->firsteager =
NULL;
1249 chkmem->nextchkmem =
NULL;
1250 chkmem->elemsize = size;
1251 chkmem->nchunks = 0;
1252 chkmem->lastchunksize = 0;
1253 chkmem->storesize = 0;
1254 chkmem->lazyfreesize = 0;
1255 chkmem->eagerfreesize = 0;
1256 chkmem->initchunksize = initchunksize;
1257 chkmem->garbagefactor = garbagefactor;
1259 chkmem->filename =
NULL;
1261 chkmem->ngarbagecalls = 0;
1262 chkmem->ngarbagefrees = 0;
1265 if( memsize !=
NULL )
1278 assert(chkmem !=
NULL);
1283 SCIPrbtreeDelete(&chkmem->rootchunk, chunk);
1284 destroyChunk(&chunk, memsize);
1287 chkmem->lazyfree =
NULL;
1288 chkmem->firsteager =
NULL;
1289 chkmem->nchunks = 0;
1290 chkmem->lastchunksize = 0;
1291 chkmem->storesize = 0;
1292 chkmem->lazyfreesize = 0;
1293 chkmem->eagerfreesize = 0;
1303 assert(chkmem !=
NULL);
1304 assert(*chkmem !=
NULL);
1312 if( memsize !=
NULL )
1313 (*memsize) -= (
long long)(
sizeof(
BMS_CHKMEM));
1327 assert(chkmem !=
NULL);
1330 if( chkmem->lazyfree ==
NULL )
1332 assert(chkmem->lazyfreesize == 0);
1335 if( chkmem->firsteager !=
NULL )
1344 assert(chkmem->lazyfree !=
NULL);
1345 assert(chkmem->lazyfreesize > 0);
1347 ptr = chkmem->lazyfree;
1348 chkmem->lazyfree = ptr->next;
1349 chkmem->lazyfreesize--;
1369 assert(chkmem !=
NULL);
1371 debugMessage(
"garbage collection for chunk block %p [elemsize: %d]\n", (
void*)chkmem, chkmem->elemsize);
1374 if( chkmem->lazyfreesize + chkmem->eagerfreesize == chkmem->storesize )
1381 chkmem->ngarbagecalls++;
1385 while( chkmem->lazyfree !=
NULL )
1388 lazyfree = chkmem->lazyfree;
1389 chkmem->lazyfree = chkmem->lazyfree->next;
1390 chkmem->lazyfreesize--;
1393 chunk =
findChunk(chkmem, (
void*)lazyfree);
1397 errorMessage(
"chunk for lazy free chunk %p not found in chunk block %p\n", (
void*)lazyfree, (
void*)chkmem);
1400 assert(chunk !=
NULL);
1404 assert(chunk->eagerfreesize > 0);
1406 assert(chkmem->lazyfreesize == 0);
1409 chunk = chkmem->firsteager;
1410 while( chunk !=
NULL && chkmem->nchunks > 1 )
1412 nexteager = chunk->nexteager;
1413 if( chunk->eagerfreesize == chunk->storesize )
1416 chkmem->ngarbagefrees++;
1432 const char* filename,
1436 assert(chkmem !=
NULL);
1437 assert(ptr !=
NULL);
1439 #if ( defined(CHECKMEM) || defined(CHECKCHKFREE) ) 1444 printError(
"Pointer %p does not belong to chunk block %p (size: %d).\n", ptr, chkmem, chkmem->elemsize);
1449 ((
FREELIST*)ptr)->next = chkmem->lazyfree;
1451 chkmem->lazyfreesize++;
1454 if( chkmem->garbagefactor >= 0 && chkmem->nchunks > 0 && chkmem->lazyfreesize >=
GARBAGE_SIZE 1455 && chkmem->lazyfreesize + chkmem->eagerfreesize
1456 > chkmem->garbagefactor * (
double)(chkmem->storesize) / (
double)(chkmem->nchunks) )
1470 const char* filename,
1478 if( chkmem ==
NULL )
1481 printError(
"Insufficient memory for chunk block.\n");
1483 debugMessage(
"created chunk memory %p [elemsize: %d]\n", (
void*)chkmem, (
int)size);
1491 const char* filename,
1495 debugMessage(
"clearing chunk memory %p [elemsize: %d]\n", (
void*)chkmem, chkmem->elemsize);
1497 if( chkmem !=
NULL )
1502 printError(
"Tried to clear null chunk block.\n");
1509 const char* filename,
1513 assert(chkmem !=
NULL);
1515 debugMessage(
"destroying chunk memory %p [elemsize: %d]\n", (
void*)*chkmem, (*chkmem)->elemsize);
1517 if( *chkmem !=
NULL )
1522 printError(
"Tried to destroy null chunk block.\n");
1530 const char* filename,
1536 assert(chkmem !=
NULL);
1537 assert((
int)size == chkmem->elemsize);
1544 printError(
"Insufficient memory for new chunk.\n");
1546 debugMessage(
"alloced %8llu bytes in %p [%s:%d]\n", (
unsigned long long)size, (
void*)ptr, filename, line);
1558 const char* filename,
1564 assert(chkmem !=
NULL);
1565 assert(source !=
NULL);
1566 assert((
int)size == chkmem->elemsize);
1580 const char* filename,
1584 assert(chkmem !=
NULL);
1585 assert((
int)size == chkmem->elemsize);
1586 assert( ptr !=
NULL );
1590 debugMessage(
"free %8d bytes in %p [%s:%d]\n", chkmem->elemsize, *ptr, filename, line);
1600 printError(
"Tried to free null chunk pointer.\n");
1609 const char* filename,
1613 assert(chkmem !=
NULL);
1614 assert((
int)size == chkmem->elemsize);
1615 assert( ptr !=
NULL );
1619 debugMessage(
"free %8d bytes in %p [%s:%d]\n", chkmem->elemsize, *ptr, filename, line);
1633 debugMessage(
"garbage collection on chunk memory %p [elemsize: %d]\n", (
void*)chkmem, chkmem->elemsize);
1643 assert(chkmem !=
NULL);
1645 return ((
long long)(chkmem->elemsize) * (
long long)(chkmem->storesize));
1671 long long tmpmemalloc = 0LL;
1672 long long tmpmemused = 0LL;
1675 assert(blkmem !=
NULL);
1676 assert(blkmem->chkmemhash !=
NULL);
1680 chkmem = blkmem->chkmemhash[i];
1681 while( chkmem !=
NULL )
1684 tmpmemalloc += ((chkmem->elemsize * chkmem->storesize) + chkmem->nchunks *
sizeof(
CHUNK) +
sizeof(
BMS_CHKMEM));
1685 tmpmemused += (chkmem->elemsize * (chkmem->storesize - chkmem->eagerfreesize - chkmem->lazyfreesize));
1686 chkmem = chkmem->nextchkmem;
1689 assert(tmpmemalloc == blkmem->memallocated);
1690 assert(tmpmemused == blkmem->memused);
1693 #define checkBlkmem(blkmem) 1711 assert(blkmem !=
NULL);
1716 chkmem = blkmem->chkmemhash[i];
1718 chkmem = chkmem->nextchkmem;
1733 return (
int) (((uint32_t)size * UINT32_C(0x9e3779b9))>>(32-
CHKHASH_POWER));
1741 const char* filename,
1749 if( blkmem !=
NULL )
1752 blkmem->chkmemhash[i] =
NULL;
1753 blkmem->initchunksize = initchunksize;
1754 blkmem->garbagefactor = garbagefactor;
1755 blkmem->memused = 0;
1756 blkmem->memallocated = 0;
1757 blkmem->maxmemused = 0;
1758 blkmem->maxmemunused = 0;
1759 blkmem->maxmemallocated = 0;
1764 printError(
"Insufficient memory for block memory header.\n");
1773 const char* filename,
1781 if( blkmem !=
NULL )
1785 chkmem = blkmem->chkmemhash[i];
1786 while( chkmem !=
NULL )
1788 nextchkmem = chkmem->nextchkmem;
1790 chkmem = nextchkmem;
1792 blkmem->chkmemhash[i] =
NULL;
1794 blkmem->memused = 0;
1795 assert(blkmem->memallocated == 0);
1800 printError(
"Tried to clear null block memory.\n");
1807 const char* filename,
1811 assert(blkmem !=
NULL);
1813 if( *blkmem !=
NULL )
1817 assert(*blkmem ==
NULL);
1822 printError(
"Tried to destroy null block memory.\n");
1831 const char* filename,
1839 assert( blkmem !=
NULL );
1846 chkmemptr = &(blkmem->chkmemhash[hashnumber]);
1847 while( *chkmemptr !=
NULL && (*chkmemptr)->elemsize != (
int)size )
1848 chkmemptr = &((*chkmemptr)->nextchkmem);
1851 if( *chkmemptr ==
NULL )
1853 *chkmemptr =
createChkmem((
int)size, blkmem->initchunksize, blkmem->garbagefactor, &blkmem->memallocated);
1854 if( *chkmemptr ==
NULL )
1857 printError(
"Insufficient memory for chunk block.\n");
1862 (*chkmemptr)->line = line;
1872 printError(
"Insufficient memory for new chunk.\n");
1874 debugMessage(
"alloced %8llu bytes in %p [%s:%d]\n", (
unsigned long long)size, ptr, filename, line);
1877 blkmem->memused += (
long long) size;
1878 blkmem->maxmemused =
MAX(blkmem->maxmemused, blkmem->memused);
1879 blkmem->maxmemunused =
MAX(blkmem->maxmemunused, blkmem->memallocated - blkmem->memused);
1880 blkmem->maxmemallocated =
MAX(blkmem->maxmemallocated, blkmem->memallocated);
1882 assert(blkmem->memused >= 0);
1883 assert(blkmem->memallocated >= 0);
1894 const char* filename,
1914 const char* filename,
1932 const char* filename,
1953 const char* filename,
1972 const char* filename,
1980 assert(oldsize == 0);
1993 alignSize(&oldsize);
1994 alignSize(&newsize);
1995 if( oldsize == newsize )
1999 if( newptr !=
NULL )
2013 const char* filename,
2021 assert(oldnum == 0);
2034 if ( oldnum == newnum )
2038 if ( newptr !=
NULL )
2050 const char* filename,
2056 assert(source !=
NULL);
2071 const char* filename,
2077 assert(source !=
NULL);
2092 const char* filename,
2099 assert(ptr !=
NULL);
2100 assert(*ptr !=
NULL);
2106 debugMessage(
"free %8llu bytes in %p [%s:%d]\n", (
unsigned long long)size, *ptr, filename, line);
2109 assert( blkmem->chkmemhash !=
NULL );
2110 chkmem = blkmem->chkmemhash[hashnumber];
2111 while( chkmem !=
NULL && chkmem->elemsize != (
int)size )
2112 chkmem = chkmem->nextchkmem;
2113 if( chkmem ==
NULL )
2116 printError(
"Tried to free pointer <%p> in block memory <%p> of unknown size %llu.\n", *ptr, (
void*)blkmem, (
unsigned long long)size);
2119 assert(chkmem->elemsize == (
int)size);
2123 blkmem->memused -= (
long long) size;
2125 blkmem->maxmemunused =
MAX(blkmem->maxmemunused, blkmem->memallocated - blkmem->memused);
2127 assert(blkmem->memused >= 0);
2128 assert(blkmem->memallocated >= 0);
2140 const char* filename,
2144 assert( blkmem !=
NULL );
2145 assert( ptr !=
NULL );
2149 else if( size != 0 )
2152 printError(
"Tried to free null block pointer.\n");
2162 const char* filename,
2166 assert( blkmem !=
NULL );
2167 assert( ptr !=
NULL );
2185 assert(blkmem !=
NULL);
2191 chkmemptr = &blkmem->chkmemhash[i];
2192 while( *chkmemptr !=
NULL )
2196 if( (*chkmemptr)->nchunks == 0 )
2200 assert((*chkmemptr)->lazyfreesize == 0);
2201 nextchkmem = (*chkmemptr)->nextchkmem;
2203 *chkmemptr = nextchkmem;
2207 chkmemptr = &(*chkmemptr)->nextchkmem;
2217 assert( blkmem !=
NULL );
2219 return blkmem->memallocated;
2227 assert( blkmem !=
NULL );
2229 return blkmem->memused;
2237 assert( blkmem !=
NULL );
2239 return blkmem->memallocated - blkmem->memused;
2247 assert( blkmem !=
NULL );
2249 return blkmem->maxmemused;
2257 assert( blkmem !=
NULL );
2259 return blkmem->maxmemunused;
2267 assert( blkmem !=
NULL );
2269 return blkmem->maxmemallocated;
2280 assert(blkmem !=
NULL);
2286 if( chkmem ==
NULL )
2289 return (
size_t)(chkmem->elemsize);
2299 int nunusedblocks = 0;
2300 int totalnchunks = 0;
2301 int totalneagerchunks = 0;
2302 int totalnelems = 0;
2303 int totalneagerelems = 0;
2304 int totalnlazyelems = 0;
2306 int totalngarbagecalls = 0;
2307 int totalngarbagefrees = 0;
2309 long long allocedmem = 0;
2310 long long freemem = 0;
2314 printInfo(
" ElSize #Chunk #Eag #Elems #EagFr #LazFr #GCl #GFr Free MBytes First Allocator\n");
2316 printInfo(
" ElSize #Chunk #Eag #Elems #EagFr #LazFr Free MBytes\n");
2319 assert(blkmem !=
NULL);
2323 chkmem = blkmem->chkmemhash[i];
2324 while( chkmem !=
NULL )
2328 int neagerchunks = 0;
2329 int neagerelems = 0;
2333 assert(chunk != NULL);
2334 assert(chunk->elemsize == chkmem->elemsize);
2335 assert(chunk->chkmem == chkmem);
2337 nelems += chunk->storesize;
2338 if( chunk->eagerfree != NULL )
2341 neagerelems += chunk->eagerfreesize;
2345 assert(nchunks == chkmem->nchunks);
2346 assert(nelems == chkmem->storesize);
2347 assert(neagerelems == chkmem->eagerfreesize);
2352 allocedmem += (
long long)chkmem->elemsize * (
long long)nelems;
2353 freemem += (
long long)chkmem->elemsize * ((
long long)neagerelems + (
long long)chkmem->lazyfreesize);
2356 printInfo(
"%7d %6d %4d %7d %7d %7d %5d %4d %5.1f%% %6.1f %s:%d\n",
2357 chkmem->elemsize, nchunks, neagerchunks, nelems,
2358 neagerelems, chkmem->lazyfreesize, chkmem->ngarbagecalls, chkmem->ngarbagefrees,
2359 100.0 * (
double) (neagerelems + chkmem->lazyfreesize) / (
double) (nelems),
2360 (
double)chkmem->elemsize * nelems / (1024.0*1024.0),
2361 chkmem->filename, chkmem->line);
2363 printInfo(
"%7d %6d %4d %7d %7d %7d %5.1f%% %6.1f\n",
2364 chkmem->elemsize, nchunks, neagerchunks, nelems,
2365 neagerelems, chkmem->lazyfreesize,
2366 100.0 * (
double) (neagerelems + chkmem->lazyfreesize) / (
double) (nelems),
2367 (
double)chkmem->elemsize * nelems / (1024.0*1024.0));
2373 printInfo(
"%7d <unused> %5d %4d %s:%d\n",
2374 chkmem->elemsize, chkmem->ngarbagecalls, chkmem->ngarbagefrees,
2375 chkmem->filename, chkmem->line);
2377 printInfo(
"%7d <unused>\n", chkmem->elemsize);
2381 totalnchunks += nchunks;
2382 totalneagerchunks += neagerchunks;
2383 totalnelems += nelems;
2384 totalneagerelems += neagerelems;
2385 totalnlazyelems += chkmem->lazyfreesize;
2387 totalngarbagecalls += chkmem->ngarbagecalls;
2388 totalngarbagefrees += chkmem->ngarbagefrees;
2390 chkmem = chkmem->nextchkmem;
2394 printInfo(
" Total %6d %4d %7d %7d %7d %5d %4d %5.1f%% %6.1f\n",
2395 totalnchunks, totalneagerchunks, totalnelems, totalneagerelems, totalnlazyelems,
2396 totalngarbagecalls, totalngarbagefrees,
2397 totalnelems > 0 ? 100.0 * (
double) (totalneagerelems + totalnlazyelems) / (
double) (totalnelems) : 0.0,
2398 (
double)allocedmem/(1024.0*1024.0));
2400 printInfo(
" Total %6d %4d %7d %7d %7d %5.1f%% %6.1f\n",
2401 totalnchunks, totalneagerchunks, totalnelems, totalneagerelems, totalnlazyelems,
2402 totalnelems > 0 ? 100.0 * (
double) (totalneagerelems + totalnlazyelems) / (
double) (totalnelems) : 0.0,
2403 (
double)allocedmem/(1024.0*1024.0));
2406 nblocks + nunusedblocks, nunusedblocks, allocedmem, freemem);
2407 if( allocedmem > 0 )
2408 printInfo(
" (%.1f%%)", 100.0 * (
double) freemem / (
double) allocedmem);
2411 printInfo(
"Memory Peaks: Used Lazy Total\n");
2412 printInfo(
" %6.1f %6.1f %6.1f MBytes\n", (
double)blkmem->maxmemused / (1024.0 * 1024.0),
2413 (
double)blkmem->maxmemunused / (1024.0 * 1024.0), (
double)blkmem->maxmemallocated / (1024.0 * 1024.0));
2422 long long allocedmem = 0;
2423 long long freemem = 0;
2426 assert(blkmem !=
NULL);
2430 chkmem = blkmem->chkmemhash[i];
2431 while( chkmem !=
NULL )
2435 int neagerelems = 0;
2439 assert(chunk != NULL);
2440 assert(chunk->elemsize == chkmem->elemsize);
2441 assert(chunk->chkmem == chkmem);
2443 nelems += chunk->storesize;
2444 if( chunk->eagerfree != NULL )
2445 neagerelems += chunk->eagerfreesize;
2448 assert(nchunks == chkmem->nchunks);
2450 assert(nelems == chkmem->storesize);
2451 assert(neagerelems == chkmem->eagerfreesize);
2455 allocedmem += (
long long)chkmem->elemsize * (
long long)nelems;
2456 freemem += (
long long)chkmem->elemsize * ((
long long)neagerelems + (
long long)chkmem->lazyfreesize);
2458 if( nelems != neagerelems + chkmem->lazyfreesize )
2462 (((
long long)nelems - (
long long)neagerelems) - (
long long)chkmem->lazyfreesize)
2463 * (
long long)(chkmem->elemsize),
2464 (nelems - neagerelems) - chkmem->lazyfreesize, (
long long)(chkmem->elemsize),
2465 chkmem->filename, chkmem->line);
2467 errorMessage(
"%" LONGINT_FORMAT
" bytes (%d elements of size %" LONGINT_FORMAT
") not freed.\n",
2468 ((nelems - neagerelems) - chkmem->lazyfreesize) * (
long long)(chkmem->elemsize),
2469 (nelems - neagerelems) - chkmem->lazyfreesize, (
long long)(chkmem->elemsize));
2473 chkmem = chkmem->nextchkmem;
2477 if( allocedmem != freemem )
2482 return allocedmem - freemem;
2513 double arraygrowfac,
2516 const char* filename,
2522 assert( arraygrowinit > 0 );
2523 assert( arraygrowfac > 0.0 );
2526 if ( buffer !=
NULL )
2532 buffer->
clean = clean;
2541 printError(
"Insufficient memory for buffer memory header.\n");
2550 const char* filename,
2556 if ( *buffer !=
NULL )
2558 i = (*buffer)->ndata;
2562 assert( ! (*buffer)->used[i] );
2576 printError(
"Tried to free null buffer memory.\n");
2586 assert( buffer !=
NULL );
2587 assert( arraygrowfac > 0.0 );
2598 assert( buffer !=
NULL );
2599 assert( arraygrowinit > 0 );
2604 #ifndef SCIP_NOBUFFERMEM 2618 assert( growfac >= 1.0 );
2620 if ( growfac == 1.0 )
2621 size =
MAX(initsize, num);
2627 initsize =
MAX(initsize, 4);
2632 while ( size < num && size > oldsize )
2635 size = (size_t)(growfac * size + initsize);
2639 if ( size <= oldsize )
2643 assert( size >= initsize );
2644 assert( size >= num );
2655 const char* filename,
2661 #ifndef SCIP_NOBUFFERMEM 2665 #ifndef SCIP_NOBUFFERMEM 2666 assert( buffer !=
NULL );
2685 printError(
"Insufficient memory for reallocating buffer data storage.\n");
2692 printError(
"Insufficient memory for reallocating buffer size storage.\n");
2699 printError(
"Insufficient memory for reallocating buffer used storage.\n");
2704 for (i = buffer->
ndata; i < newsize; ++i)
2707 buffer->
size[i] = 0;
2710 buffer->
ndata = newsize;
2716 assert( ! buffer->
used[bufnum] );
2717 if ( buffer->
size[bufnum] < size )
2728 char* tmpptr = (
char*)(buffer->
data[bufnum]);
2729 size_t inc = buffer->
size[bufnum] /
sizeof(*tmpptr);
2734 assert( newsize > buffer->
size[bufnum] );
2736 buffer->
size[bufnum] = newsize;
2738 if ( buffer->
data[bufnum] ==
NULL )
2741 printError(
"Insufficient memory for reallocating buffer storage.\n");
2745 assert( buffer->
size[bufnum] >= size );
2747 #ifdef CHECKCLEANBUFFER 2751 char* tmpptr = (
char*)(buffer->
data[bufnum]);
2752 unsigned int inc = buffer->
size[bufnum] /
sizeof(*tmpptr);
2755 while( --tmpptr >= (
char*)(buffer->
data[bufnum]) )
2756 assert(*tmpptr ==
'\0');
2760 ptr = buffer->
data[bufnum];
2764 debugMessage(
"Allocated buffer %llu/%llu at %p of size %llu (required size: %llu) for pointer %p.\n",
2765 (
unsigned long long)bufnum, (
unsigned long long)(buffer->
ndata), buffer->
data[bufnum],
2766 (
unsigned long long)(buffer->
size[bufnum]), (
unsigned long long)size, ptr);
2789 const char* filename,
2810 const char* filename,
2831 const char* filename,
2850 const char* filename,
2855 #ifndef SCIP_NOBUFFERMEM 2859 #ifndef SCIP_NOBUFFERMEM 2860 assert( buffer !=
NULL );
2862 assert(!buffer->
clean);
2875 while ( bufnum > 0 && buffer->
data[bufnum] != ptr )
2879 assert( buffer->
data[bufnum] == newptr );
2880 assert( buffer->
used[bufnum] );
2881 assert( buffer->
size[bufnum] >= 1 );
2884 if ( size > buffer->
size[bufnum] )
2891 assert( newsize > buffer->
size[bufnum] );
2893 buffer->
size[bufnum] = newsize;
2894 if ( buffer->
data[bufnum] ==
NULL )
2897 printError(
"Insufficient memory for reallocating buffer storage.\n");
2900 newptr = buffer->
data[bufnum];
2902 assert( buffer->
size[bufnum] >= size );
2903 assert( newptr == buffer->
data[bufnum] );
2905 debugMessage(
"Reallocated buffer %llu/%llu at %p to size %llu (required size: %llu) for pointer %p.\n",
2906 (
unsigned long long)bufnum, (
unsigned long long)(buffer->
ndata), buffer->
data[bufnum],
2907 (
unsigned long long)(buffer->
size[bufnum]), (
unsigned long long)size, newptr);
2922 const char* filename,
2944 const char* filename,
2965 const char* filename,
2971 assert( source !=
NULL );
2989 const char* filename,
2995 assert( source !=
NULL );
3012 const char* filename,
3018 assert( buffer !=
NULL );
3021 assert( ptr !=
NULL );
3022 assert( *ptr !=
NULL );
3029 while ( bufnum > 0 && buffer->
data[bufnum] != *ptr )
3032 #ifdef CHECKBUFFERORDER 3033 if ( bufnum < buffer->firstfree - 1 )
3035 warningMessage(
"[%s:%d]: freeing buffer in wrong order.\n", filename, line);
3040 if ( bufnum == 0 && buffer->
data[bufnum] != *ptr )
3043 printError(
"Tried to free unkown buffer pointer.\n");
3046 if ( ! buffer->
used[bufnum] )
3049 printError(
"Tried to free buffer pointer already freed.\n");
3054 #ifdef CHECKCLEANBUFFER 3059 uint8_t* tmpptr = (uint8_t*)(buffer->
data[bufnum]);
3061 for( i = 0; i < buffer->
size[bufnum]; ++i )
3062 assert(tmpptr[i] == 0);
3066 assert( buffer->
data[bufnum] == *ptr );
3072 debugMessage(
"Freed buffer %llu/%llu at %p of size %llu for pointer %p, first free is %llu.\n",
3073 (
unsigned long long)bufnum, (
unsigned long long)(buffer->
ndata), buffer->
data[bufnum],
3074 (
unsigned long long)(buffer->
size[bufnum]), *ptr, (
unsigned long long)(buffer->
firstfree));
3083 const char* filename,
3087 assert( ptr !=
NULL );
3089 #ifndef SCIP_NOBUFFERMEM 3095 printError(
"Tried to free null buffer pointer.\n");
3106 const char* filename,
3110 assert( ptr !=
NULL );
3114 #ifndef SCIP_NOBUFFERMEM 3127 assert( buffer !=
NULL );
3138 size_t totalmem = 0UL;
3141 assert( buffer !=
NULL );
3142 for (i = 0; i < buffer->
ndata; ++i)
3143 totalmem += buffer->
size[i];
3144 assert( totalmem == buffer->
totalmem );
3147 return (
long long) buffer->
totalmem;
3158 assert( buffer !=
NULL );
3161 for (i = 0; i < buffer->
ndata; ++i)
3163 printf(
"[%c] %8llu bytes at %p\n", buffer->
used[i] ?
'*' :
' ', (
unsigned long long)(buffer->
size[i]), buffer->
data[i]);
3164 totalmem += buffer->
size[i];
3166 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
static void freeChunk(CHUNK **chunk, long long *memsize)
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 * BMSallocClearBlockMemory_call(BMS_BLKMEM *blkmem, size_t size, 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 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)
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)
static void destroyChunk(CHUNK **chunk, long long *memsize)
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)
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