37 #define __STDC_LIMIT_MACROS 48 #include "scip/config.h" 65 #ifndef SCIP_THREADSAFE 69 #ifdef ENABLE_MEMLIST_CHECKS 85 #ifdef SCIPdebugMessage 86 #define debugMessage SCIPdebugMessage 87 #define errorMessage SCIPerrorMessage 89 #define debugMessage while( FALSE ) printf 90 #define errorMessage printf 91 #define printErrorHeader(f,l) printf("[%s:%d] ERROR: ", f, l) 92 #define printError printf 95 #ifdef ENABLE_MEMLIST_CHECKS 96 #define warningMessage printf 98 #define printInfo printf 106 #define MAX(x,y) ((x) >= (y) ? (x) : (y)) 107 #define MIN(x,y) ((x) <= (y) ? (x) : (y)) 110 #ifndef SCIP_LONGINT_FORMAT 111 #if defined(_WIN32) || defined(_WIN64) 112 #define LONGINT_FORMAT "I64d" 114 #define LONGINT_FORMAT "lld" 117 #define LONGINT_FORMAT SCIP_LONGINT_FORMAT 120 #ifndef SCIP_MAXMEMSIZE 122 #define MAXMEMSIZE SIZE_MAX / 2 124 #define MAXMEMSIZE SCIP_MAXMEMSIZE 129 #if defined(_WIN32) || defined(_WIN64) || defined(__STDC__) 130 #define INLINE __inline 132 #define INLINE inline 143 #if !defined(NDEBUG) && defined(ENABLE_MEMLIST_CHECKS) 145 typedef struct Memlist MEMLIST;
157 static MEMLIST* memlist =
NULL;
158 static size_t memused = 0;
167 MEMLIST* list = memlist;
170 while( list !=
NULL )
175 assert(used == memused);
178 #define checkMemlist() 186 const char* filename,
192 assert(ptr !=
NULL && size > 0);
194 list = (MEMLIST*)malloc(
sizeof(MEMLIST));
195 assert(list !=
NULL);
199 list->filename = strdup(filename);
200 assert(list->filename !=
NULL);
202 list->next = memlist;
212 const char* filename,
223 while( list !=
NULL && ptr != list->ptr )
225 listptr = &(list->next);
230 assert(ptr == list->ptr);
232 *listptr = list->next;
233 assert( list->size <= memused );
234 memused -= list->size;
235 free(list->filename);
241 printError(
"Tried to free unknown pointer <%p>.\n", ptr);
254 while( list !=
NULL && ptr != list->ptr )
272 while( list !=
NULL )
274 printInfo(
"%12p %8llu %s:%d\n", list->ptr, (
unsigned long long) list->size, list->filename, list->line);
278 printInfo(
"Total: %8llu\n", (
unsigned long long) memused);
279 if( used != memused )
281 errorMessage(
"Used memory in list sums up to %llu instead of %llu\n", (
unsigned long long)used, (
unsigned long long)memused);
291 if( memlist !=
NULL || memused > 0 )
293 warningMessage(
"Memory list not empty.\n");
303 return (
long long) memused;
308 #define addMemlistEntry(ptr, size, filename, line) do { (void) (ptr); (void) (size); (void) (filename); (void) (line); } while(0) 309 #define removeMemlistEntry(ptr, filename, line) do { (void) (ptr); (void) (filename); (void) (line); } while(0) 329 printInfo(
"Optimized, threadsafe version of memory shell linked - no memory diagnostics available.\n");
353 const char* filename,
359 assert(typesize > 0);
361 debugMessage(
"calloc %llu elements of %llu bytes [%s:%d]\n", (
unsigned long long)num, (
unsigned long long)typesize,
374 typesize =
MAX(typesize, 1);
375 ptr = calloc(num, typesize);
380 printError(
"Insufficient memory for allocation of %llu bytes.\n", (
unsigned long long)(num) * (typesize));
391 const char* filename,
397 debugMessage(
"malloc %llu bytes [%s:%d]\n", (
unsigned long long)size, filename, line);
414 printError(
"Insufficient memory for allocation of %llu bytes.\n", (
unsigned long long)size);
426 const char* filename,
433 debugMessage(
"malloc %llu elements of %llu bytes [%s:%d]\n",
434 (
unsigned long long)num, (
unsigned long long)typesize, filename, line);
445 size = num * typesize;
452 printError(
"Insufficient memory for allocation of %llu bytes.\n", (
unsigned long long)size);
464 const char* filename,
483 newptr = realloc(ptr, size);
488 printError(
"Insufficient memory for reallocation of %llu bytes.\n", (
unsigned long long)size);
501 const char* filename,
520 size = num * typesize;
522 newptr = realloc(ptr, size);
527 printError(
"Insufficient memory for reallocation of %llu bytes.\n", (
unsigned long long)size);
544 memset(ptr, 0, size);
558 assert(source !=
NULL);
559 memcpy(ptr, source, size);
575 assert(source !=
NULL);
576 memmove(ptr, source, size);
584 const char* filename,
590 assert(source !=
NULL || size == 0);
604 const char* filename,
610 assert(source !=
NULL || num == 0);
622 const char* filename,
626 assert( ptr !=
NULL );
644 const char* filename,
648 assert( ptr !=
NULL );
665 #define CHKHASH_POWER 10 666 #define CHKHASH_SIZE (1<<CHKHASH_POWER) 673 long long memallocated;
674 long long maxmemused;
675 long long maxmemunused;
676 long long maxmemallocated;
693 #define CHUNKLENGTH_MIN 1024 694 #define CHUNKLENGTH_MAX 1048576 695 #define STORESIZE_MAX 8192 696 #define GARBAGE_SIZE 256 697 #define ALIGNMENT (sizeof(FREELIST)) 748 #define CHUNK_LT(ptr,chunk) ptr < chunk->store 749 #define CHUNK_GT(ptr,chunk) ptr >= chunk->storeend 793 assert(chunk !=
NULL);
794 assert(chunk->store <= chunk->storeend);
796 return (ptr >= (
void*)(chunk->store) && ptr < (
void*)(chunk->storeend));
812 assert(chkmem !=
NULL);
815 if( rbTreeFindChunk(chkmem->rootchunk, ptr, &chunk) == 0 )
829 assert(chkmem !=
NULL);
850 assert(chunk !=
NULL);
851 assert(chunk->store !=
NULL);
852 assert(chunk->storeend == (
void*)((
char*)(chunk->store) + chunk->elemsize * chunk->storesize));
853 assert(chunk->chkmem !=
NULL);
854 assert(chunk->chkmem->elemsize == chunk->elemsize);
856 if( chunk->eagerfree ==
NULL )
857 assert(chunk->nexteager ==
NULL && chunk->preveager ==
NULL);
858 else if( chunk->preveager ==
NULL )
859 assert(chunk->chkmem->firsteager == chunk);
861 if( chunk->nexteager !=
NULL )
862 assert(chunk->nexteager->preveager == chunk);
863 if( chunk->preveager !=
NULL )
864 assert(chunk->preveager->nexteager == chunk);
867 eager = chunk->eagerfree;
868 while( eager !=
NULL )
874 assert(chunk->eagerfreesize == eagerfreesize);
889 assert(chkmem !=
NULL);
900 storesize += chunk->storesize;
901 eagerfreesize += chunk->eagerfreesize;
904 assert(chkmem->nchunks == nchunks);
905 assert(chkmem->storesize == storesize);
906 assert(chkmem->eagerfreesize == eagerfreesize);
908 assert(((
unsigned int) (chkmem->eagerfreesize == 0)) ^ ( (
unsigned int) (chkmem->firsteager !=
NULL)));
910 if( chkmem->firsteager !=
NULL )
911 assert(chkmem->firsteager->preveager ==
NULL);
913 lazy = chkmem->lazyfree;
914 while( lazy !=
NULL )
917 assert(chunk !=
NULL);
918 assert(chunk->chkmem == chkmem);
922 assert(chkmem->lazyfreesize == lazyfreesize);
925 #define checkChunk(chunk) 926 #define checkChkmem(chkmem) 942 assert(chkmem !=
NULL);
943 assert(chunk !=
NULL);
944 assert(chunk->store !=
NULL);
946 debugMessage(
"linking chunk %p to chunk block %p [elemsize:%d, %d chunks]\n",
947 (
void*)chunk, (
void*)chkmem, chkmem->elemsize, chkmem->nchunks);
949 pos = rbTreeFindChunk(chkmem->rootchunk, chunk->store, &parent);
955 chkmem->storesize += chunk->storesize;
968 assert(chunk !=
NULL);
969 assert(chunk->eagerfree ==
NULL);
970 assert(chunk->nexteager ==
NULL);
971 assert(chunk->preveager ==
NULL);
973 chkmem = chunk->chkmem;
974 assert(chkmem !=
NULL);
975 assert(chkmem->elemsize == chunk->elemsize);
977 debugMessage(
"unlinking chunk %p from chunk block %p [elemsize:%d, %d chunks]\n",
978 (
void*)chunk, (
void*)chkmem, chkmem->elemsize, chkmem->nchunks);
984 chkmem->storesize -= chunk->storesize;
994 assert(chunk->chkmem == chkmem);
995 assert(chunk->nexteager ==
NULL);
996 assert(chunk->preveager ==
NULL);
998 chunk->nexteager = chkmem->firsteager;
999 chunk->preveager =
NULL;
1000 if( chkmem->firsteager !=
NULL )
1002 assert(chkmem->firsteager->preveager ==
NULL);
1003 chkmem->firsteager->preveager = chunk;
1005 chkmem->firsteager = chunk;
1014 assert(chunk !=
NULL);
1015 assert(chunk->eagerfreesize == 0 || chunk->eagerfreesize == chunk->storesize);
1017 if( chunk->nexteager !=
NULL )
1018 chunk->nexteager->preveager = chunk->preveager;
1019 if( chunk->preveager !=
NULL )
1020 chunk->preveager->nexteager = chunk->nexteager;
1023 assert(chunk->chkmem->firsteager == chunk);
1024 chunk->chkmem->firsteager = chunk->nexteager;
1026 chunk->nexteager =
NULL;
1027 chunk->preveager =
NULL;
1028 chunk->eagerfree =
NULL;
1046 assert(chkmem !=
NULL);
1048 debugMessage(
"creating new chunk in chunk block %p [elemsize: %d]\n", (
void*)chkmem, chkmem->elemsize);
1051 if( chkmem->nchunks == 0 )
1052 storesize = chkmem->initchunksize;
1054 storesize = 2 * chkmem->lastchunksize;
1055 assert(storesize > 0);
1059 storesize =
MAX(storesize, 1);
1060 chkmem->lastchunksize = storesize;
1064 assert( chkmem->elemsize < INT_MAX / storesize );
1065 assert(
sizeof(
CHUNK) <
MAXMEMSIZE - (
size_t)(storesize * chkmem->elemsize) );
1067 if( newchunk ==
NULL )
1071 newchunk->store = (
void*) ((
char*) newchunk +
sizeof(
CHUNK));
1072 newchunk->storeend = (
void*) ((
char*) newchunk->store + (ptrdiff_t)storesize * chkmem->elemsize);
1073 newchunk->eagerfree =
NULL;
1074 newchunk->nexteager =
NULL;
1075 newchunk->preveager =
NULL;
1076 newchunk->chkmem = chkmem;
1077 newchunk->elemsize = chkmem->elemsize;
1078 newchunk->storesize = storesize;
1079 newchunk->eagerfreesize = 0;
1081 if( memsize !=
NULL )
1082 (*memsize) += ((
long long)((
long long)
sizeof(
CHUNK) + (
long long)storesize * chkmem->elemsize));
1084 debugMessage(
"allocated new chunk %p: %d elements with size %d\n", (
void*)newchunk, newchunk->storesize, newchunk->elemsize);
1089 for( i = 0; i < newchunk->storesize - 1; ++i )
1091 freelist = (
FREELIST*) newchunk->store + (ptrdiff_t)i * chkmem->elemsize / (ptrdiff_t)
sizeof(
FREELIST*);
1092 freelist->next = (
FREELIST*) newchunk->store + ((ptrdiff_t)i + 1) * chkmem->elemsize / (ptrdiff_t)
sizeof(
FREELIST*);
1095 freelist = (
FREELIST*) newchunk->store + ((ptrdiff_t) newchunk->storesize - 1) * chkmem->elemsize / (ptrdiff_t)
sizeof(
FREELIST*);
1096 freelist->next = chkmem->lazyfree;
1097 chkmem->lazyfree = (
FREELIST*) (newchunk->store);
1098 chkmem->lazyfreesize += newchunk->storesize;
1115 assert(chunk !=
NULL);
1116 assert(*chunk !=
NULL);
1120 if( memsize !=
NULL )
1121 (*memsize) -= ((
long long)
sizeof(
CHUNK) + (
long long)(*chunk)->storesize * (*chunk)->elemsize);
1134 assert(chunk !=
NULL);
1135 assert(*chunk !=
NULL);
1136 assert((*chunk)->store !=
NULL);
1137 assert((*chunk)->eagerfree !=
NULL);
1138 assert((*chunk)->chkmem !=
NULL);
1139 assert((*chunk)->chkmem->rootchunk !=
NULL);
1140 assert((*chunk)->chkmem->firsteager !=
NULL);
1141 assert((*chunk)->eagerfreesize == (*chunk)->storesize);
1143 debugMessage(
"freeing chunk %p of chunk block %p [elemsize: %d]\n", (
void*)*chunk, (
void*)(*chunk)->chkmem, (*chunk)->chkmem->elemsize);
1146 (*chunk)->chkmem->eagerfreesize -= (*chunk)->eagerfreesize;
1147 assert((*chunk)->chkmem->eagerfreesize >= 0);
1167 assert(chunk !=
NULL);
1168 assert(chunk->eagerfree !=
NULL);
1169 assert(chunk->eagerfreesize > 0);
1170 assert(chunk->chkmem !=
NULL);
1172 debugMessage(
"allocating chunk element in chunk %p [elemsize: %d]\n", (
void*)chunk, chunk->chkmem->elemsize);
1175 ptr = chunk->eagerfree;
1176 chunk->eagerfree = ptr->next;
1177 chunk->eagerfreesize--;
1178 chunk->chkmem->eagerfreesize--;
1180 assert((chunk->eagerfreesize == 0 && chunk->eagerfree ==
NULL)
1181 || (chunk->eagerfreesize != 0 && chunk->eagerfree !=
NULL));
1182 assert(chunk->chkmem->eagerfreesize >= 0);
1185 if( chunk->eagerfree ==
NULL )
1187 assert(chunk->eagerfreesize == 0);
1203 assert(chunk !=
NULL);
1204 assert(chunk->chkmem !=
NULL);
1207 debugMessage(
"freeing chunk element %p of chunk %p [elemsize: %d]\n", (
void*)ptr, (
void*)chunk, chunk->chkmem->elemsize);
1210 if( chunk->eagerfree ==
NULL )
1212 assert(chunk->eagerfreesize == 0);
1217 ((
FREELIST*)ptr)->next = chunk->eagerfree;
1219 chunk->eagerfreesize++;
1220 chunk->chkmem->eagerfreesize++;
1241 if( chkmem ==
NULL )
1244 chkmem->lazyfree =
NULL;
1245 chkmem->rootchunk =
NULL;
1246 chkmem->firsteager =
NULL;
1247 chkmem->nextchkmem =
NULL;
1248 chkmem->elemsize = size;
1249 chkmem->nchunks = 0;
1250 chkmem->lastchunksize = 0;
1251 chkmem->storesize = 0;
1252 chkmem->lazyfreesize = 0;
1253 chkmem->eagerfreesize = 0;
1254 chkmem->initchunksize = initchunksize;
1255 chkmem->garbagefactor = garbagefactor;
1257 chkmem->filename =
NULL;
1259 chkmem->ngarbagecalls = 0;
1260 chkmem->ngarbagefrees = 0;
1263 if( memsize !=
NULL )
1276 assert(chkmem !=
NULL);
1281 SCIPrbtreeDelete(&chkmem->rootchunk, chunk);
1282 destroyChunk(&chunk, memsize);
1285 chkmem->lazyfree =
NULL;
1286 chkmem->firsteager =
NULL;
1287 chkmem->nchunks = 0;
1288 chkmem->lastchunksize = 0;
1289 chkmem->storesize = 0;
1290 chkmem->lazyfreesize = 0;
1291 chkmem->eagerfreesize = 0;
1301 assert(chkmem !=
NULL);
1302 assert(*chkmem !=
NULL);
1310 if( memsize !=
NULL )
1311 (*memsize) -= (
long long)(
sizeof(
BMS_CHKMEM));
1325 assert(chkmem !=
NULL);
1328 if( chkmem->lazyfree ==
NULL )
1330 assert(chkmem->lazyfreesize == 0);
1333 if( chkmem->firsteager !=
NULL )
1342 assert(chkmem->lazyfree !=
NULL);
1343 assert(chkmem->lazyfreesize > 0);
1345 ptr = chkmem->lazyfree;
1346 chkmem->lazyfree = ptr->next;
1347 chkmem->lazyfreesize--;
1367 assert(chkmem !=
NULL);
1369 debugMessage(
"garbage collection for chunk block %p [elemsize: %d]\n", (
void*)chkmem, chkmem->elemsize);
1372 if( chkmem->lazyfreesize + chkmem->eagerfreesize == chkmem->storesize )
1379 chkmem->ngarbagecalls++;
1383 while( chkmem->lazyfree !=
NULL )
1386 lazyfree = chkmem->lazyfree;
1387 chkmem->lazyfree = chkmem->lazyfree->next;
1388 chkmem->lazyfreesize--;
1391 chunk =
findChunk(chkmem, (
void*)lazyfree);
1395 errorMessage(
"chunk for lazy free chunk %p not found in chunk block %p\n", (
void*)lazyfree, (
void*)chkmem);
1398 assert(chunk !=
NULL);
1402 assert(chunk->eagerfreesize > 0);
1404 assert(chkmem->lazyfreesize == 0);
1407 chunk = chkmem->firsteager;
1408 while( chunk !=
NULL && chkmem->nchunks > 1 )
1410 nexteager = chunk->nexteager;
1411 if( chunk->eagerfreesize == chunk->storesize )
1414 chkmem->ngarbagefrees++;
1430 const char* filename,
1434 assert(chkmem !=
NULL);
1435 assert(ptr !=
NULL);
1437 #if ( defined(CHECKMEM) || defined(CHECKCHKFREE) ) 1442 printError(
"Pointer %p does not belong to chunk block %p (size: %d).\n", ptr, chkmem, chkmem->elemsize);
1447 ((
FREELIST*)ptr)->next = chkmem->lazyfree;
1449 chkmem->lazyfreesize++;
1452 if( chkmem->garbagefactor >= 0 && chkmem->nchunks > 0 && chkmem->lazyfreesize >=
GARBAGE_SIZE 1453 && chkmem->lazyfreesize + chkmem->eagerfreesize
1454 > chkmem->garbagefactor * (
double)(chkmem->storesize) / (
double)(chkmem->nchunks) )
1468 const char* filename,
1476 if( chkmem ==
NULL )
1479 printError(
"Insufficient memory for chunk block.\n");
1481 debugMessage(
"created chunk memory %p [elemsize: %d]\n", (
void*)chkmem, (
int)size);
1489 const char* filename,
1493 debugMessage(
"clearing chunk memory %p [elemsize: %d]\n", (
void*)chkmem, chkmem->elemsize);
1495 if( chkmem !=
NULL )
1500 printError(
"Tried to clear null chunk block.\n");
1507 const char* filename,
1511 assert(chkmem !=
NULL);
1513 debugMessage(
"destroying chunk memory %p [elemsize: %d]\n", (
void*)*chkmem, (*chkmem)->elemsize);
1515 if( *chkmem !=
NULL )
1520 printError(
"Tried to destroy null chunk block.\n");
1528 const char* filename,
1534 assert(chkmem !=
NULL);
1535 assert((
int)size == chkmem->elemsize);
1542 printError(
"Insufficient memory for new chunk.\n");
1544 debugMessage(
"alloced %8llu bytes in %p [%s:%d]\n", (
unsigned long long)size, (
void*)ptr, filename, line);
1556 const char* filename,
1562 assert(chkmem !=
NULL);
1563 assert(source !=
NULL);
1564 assert((
int)size == chkmem->elemsize);
1578 const char* filename,
1582 assert(chkmem !=
NULL);
1583 assert((
int)size == chkmem->elemsize);
1584 assert( ptr !=
NULL );
1588 debugMessage(
"free %8d bytes in %p [%s:%d]\n", chkmem->elemsize, *ptr, filename, line);
1598 printError(
"Tried to free null chunk pointer.\n");
1607 const char* filename,
1611 assert(chkmem !=
NULL);
1612 assert((
int)size == chkmem->elemsize);
1613 assert( ptr !=
NULL );
1617 debugMessage(
"free %8d bytes in %p [%s:%d]\n", chkmem->elemsize, *ptr, filename, line);
1631 debugMessage(
"garbage collection on chunk memory %p [elemsize: %d]\n", (
void*)chkmem, chkmem->elemsize);
1641 assert(chkmem !=
NULL);
1643 return ((
long long)(chkmem->elemsize) * (
long long)(chkmem->storesize));
1669 long long tmpmemalloc = 0LL;
1670 long long tmpmemused = 0LL;
1673 assert(blkmem !=
NULL);
1674 assert(blkmem->chkmemhash !=
NULL);
1678 chkmem = blkmem->chkmemhash[i];
1679 while( chkmem !=
NULL )
1682 tmpmemalloc += ((chkmem->elemsize * chkmem->storesize) + chkmem->nchunks *
sizeof(
CHUNK) +
sizeof(
BMS_CHKMEM));
1683 tmpmemused += (chkmem->elemsize * (chkmem->storesize - chkmem->eagerfreesize - chkmem->lazyfreesize));
1684 chkmem = chkmem->nextchkmem;
1687 assert(tmpmemalloc == blkmem->memallocated);
1688 assert(tmpmemused == blkmem->memused);
1691 #define checkBlkmem(blkmem) 1709 assert(blkmem !=
NULL);
1714 chkmem = blkmem->chkmemhash[i];
1716 chkmem = chkmem->nextchkmem;
1731 return (
int) (((uint32_t)size * UINT32_C(0x9e3779b9))>>(32-
CHKHASH_POWER));
1739 const char* filename,
1747 if( blkmem !=
NULL )
1750 blkmem->chkmemhash[i] =
NULL;
1751 blkmem->initchunksize = initchunksize;
1752 blkmem->garbagefactor = garbagefactor;
1753 blkmem->memused = 0;
1754 blkmem->memallocated = 0;
1755 blkmem->maxmemused = 0;
1756 blkmem->maxmemunused = 0;
1757 blkmem->maxmemallocated = 0;
1762 printError(
"Insufficient memory for block memory header.\n");
1771 const char* filename,
1779 if( blkmem !=
NULL )
1783 chkmem = blkmem->chkmemhash[i];
1784 while( chkmem !=
NULL )
1786 nextchkmem = chkmem->nextchkmem;
1788 chkmem = nextchkmem;
1790 blkmem->chkmemhash[i] =
NULL;
1792 blkmem->memused = 0;
1793 assert(blkmem->memallocated == 0);
1798 printError(
"Tried to clear null block memory.\n");
1805 const char* filename,
1809 assert(blkmem !=
NULL);
1811 if( *blkmem !=
NULL )
1815 assert(*blkmem ==
NULL);
1820 printError(
"Tried to destroy null block memory.\n");
1829 const char* filename,
1837 assert( blkmem !=
NULL );
1844 chkmemptr = &(blkmem->chkmemhash[hashnumber]);
1845 while( *chkmemptr !=
NULL && (*chkmemptr)->elemsize != (
int)size )
1846 chkmemptr = &((*chkmemptr)->nextchkmem);
1849 if( *chkmemptr ==
NULL )
1851 *chkmemptr =
createChkmem((
int)size, blkmem->initchunksize, blkmem->garbagefactor, &blkmem->memallocated);
1852 if( *chkmemptr ==
NULL )
1855 printError(
"Insufficient memory for chunk block.\n");
1860 (*chkmemptr)->line = line;
1868 (*chkmemptr)->line = line;
1878 printError(
"Insufficient memory for new chunk.\n");
1880 debugMessage(
"alloced %8llu bytes in %p [%s:%d]\n", (
unsigned long long)size, ptr, filename, line);
1883 blkmem->memused += (
long long) size;
1884 blkmem->maxmemused =
MAX(blkmem->maxmemused, blkmem->memused);
1885 blkmem->maxmemunused =
MAX(blkmem->maxmemunused, blkmem->memallocated - blkmem->memused);
1886 blkmem->maxmemallocated =
MAX(blkmem->maxmemallocated, blkmem->memallocated);
1888 assert(blkmem->memused >= 0);
1889 assert(blkmem->memallocated >= 0);
1900 const char* filename,
1920 const char* filename,
1938 const char* filename,
1959 const char* filename,
1978 const char* filename,
1986 assert(oldsize == 0);
1999 alignSize(&oldsize);
2000 alignSize(&newsize);
2001 if( oldsize == newsize )
2005 if( newptr !=
NULL )
2019 const char* filename,
2027 assert(oldnum == 0);
2040 if ( oldnum == newnum )
2044 if ( newptr !=
NULL )
2056 const char* filename,
2062 assert(source !=
NULL);
2077 const char* filename,
2083 assert(source !=
NULL);
2098 const char* filename,
2105 assert(ptr !=
NULL);
2106 assert(*ptr !=
NULL);
2112 debugMessage(
"free %8llu bytes in %p [%s:%d]\n", (
unsigned long long)size, *ptr, filename, line);
2115 assert( blkmem->chkmemhash !=
NULL );
2116 chkmem = blkmem->chkmemhash[hashnumber];
2117 while( chkmem !=
NULL && chkmem->elemsize != (
int)size )
2118 chkmem = chkmem->nextchkmem;
2119 if( chkmem ==
NULL )
2122 printError(
"Tried to free pointer <%p> in block memory <%p> of unknown size %llu.\n", *ptr, (
void*)blkmem, (
unsigned long long)size);
2125 assert(chkmem->elemsize == (
int)size);
2129 blkmem->memused -= (
long long) size;
2131 blkmem->maxmemunused =
MAX(blkmem->maxmemunused, blkmem->memallocated - blkmem->memused);
2133 assert(blkmem->memused >= 0);
2134 assert(blkmem->memallocated >= 0);
2146 const char* filename,
2150 assert( blkmem !=
NULL );
2151 assert( ptr !=
NULL );
2155 else if( size != 0 )
2158 printError(
"Tried to free null block pointer.\n");
2168 const char* filename,
2172 assert( blkmem !=
NULL );
2173 assert( ptr !=
NULL );
2191 assert(blkmem !=
NULL);
2197 chkmemptr = &blkmem->chkmemhash[i];
2198 while( *chkmemptr !=
NULL )
2202 if( (*chkmemptr)->nchunks == 0 )
2206 assert((*chkmemptr)->lazyfreesize == 0);
2207 nextchkmem = (*chkmemptr)->nextchkmem;
2209 *chkmemptr = nextchkmem;
2213 chkmemptr = &(*chkmemptr)->nextchkmem;
2223 assert( blkmem !=
NULL );
2225 return blkmem->memallocated;
2233 assert( blkmem !=
NULL );
2235 return blkmem->memused;
2243 assert( blkmem !=
NULL );
2245 return blkmem->memallocated - blkmem->memused;
2253 assert( blkmem !=
NULL );
2255 return blkmem->maxmemused;
2263 assert( blkmem !=
NULL );
2265 return blkmem->maxmemunused;
2273 assert( blkmem !=
NULL );
2275 return blkmem->maxmemallocated;
2286 assert(blkmem !=
NULL);
2292 if( chkmem ==
NULL )
2295 return (
size_t)(chkmem->elemsize);
2305 int nunusedblocks = 0;
2306 int totalnchunks = 0;
2307 int totalneagerchunks = 0;
2308 int totalnelems = 0;
2309 int totalneagerelems = 0;
2310 int totalnlazyelems = 0;
2312 int totalngarbagecalls = 0;
2313 int totalngarbagefrees = 0;
2315 long long allocedmem = 0;
2316 long long freemem = 0;
2320 printInfo(
" ElSize #Chunk #Eag #Elems #EagFr #LazFr #GCl #GFr Free MBytes First Allocator\n");
2322 printInfo(
" ElSize #Chunk #Eag #Elems #EagFr #LazFr Free MBytes\n");
2325 assert(blkmem !=
NULL);
2329 chkmem = blkmem->chkmemhash[i];
2330 while( chkmem !=
NULL )
2334 int neagerchunks = 0;
2335 int neagerelems = 0;
2339 assert(chunk != NULL);
2340 assert(chunk->elemsize == chkmem->elemsize);
2341 assert(chunk->chkmem == chkmem);
2343 nelems += chunk->storesize;
2344 if( chunk->eagerfree != NULL )
2347 neagerelems += chunk->eagerfreesize;
2351 assert(nchunks == chkmem->nchunks);
2352 assert(nelems == chkmem->storesize);
2353 assert(neagerelems == chkmem->eagerfreesize);
2358 allocedmem += (
long long)chkmem->elemsize * (
long long)nelems;
2359 freemem += (
long long)chkmem->elemsize * ((
long long)neagerelems + (
long long)chkmem->lazyfreesize);
2362 printInfo(
"%7d %6d %4d %7d %7d %7d %5d %4d %5.1f%% %6.1f %s:%d\n",
2363 chkmem->elemsize, nchunks, neagerchunks, nelems,
2364 neagerelems, chkmem->lazyfreesize, chkmem->ngarbagecalls, chkmem->ngarbagefrees,
2365 100.0 * (
double) (neagerelems + chkmem->lazyfreesize) / (
double) (nelems),
2366 (
double)chkmem->elemsize * nelems / (1024.0*1024.0),
2367 chkmem->filename, chkmem->line);
2369 printInfo(
"%7d %6d %4d %7d %7d %7d %5.1f%% %6.1f\n",
2370 chkmem->elemsize, nchunks, neagerchunks, nelems,
2371 neagerelems, chkmem->lazyfreesize,
2372 100.0 * (
double) (neagerelems + chkmem->lazyfreesize) / (
double) (nelems),
2373 (
double)chkmem->elemsize * nelems / (1024.0*1024.0));
2379 printInfo(
"%7d <unused> %5d %4d %s:%d\n",
2380 chkmem->elemsize, chkmem->ngarbagecalls, chkmem->ngarbagefrees,
2381 chkmem->filename, chkmem->line);
2383 printInfo(
"%7d <unused>\n", chkmem->elemsize);
2387 totalnchunks += nchunks;
2388 totalneagerchunks += neagerchunks;
2389 totalnelems += nelems;
2390 totalneagerelems += neagerelems;
2391 totalnlazyelems += chkmem->lazyfreesize;
2393 totalngarbagecalls += chkmem->ngarbagecalls;
2394 totalngarbagefrees += chkmem->ngarbagefrees;
2396 chkmem = chkmem->nextchkmem;
2400 printInfo(
" Total %6d %4d %7d %7d %7d %5d %4d %5.1f%% %6.1f\n",
2401 totalnchunks, totalneagerchunks, totalnelems, totalneagerelems, totalnlazyelems,
2402 totalngarbagecalls, totalngarbagefrees,
2403 totalnelems > 0 ? 100.0 * (
double) (totalneagerelems + totalnlazyelems) / (
double) (totalnelems) : 0.0,
2404 (
double)allocedmem/(1024.0*1024.0));
2406 printInfo(
" Total %6d %4d %7d %7d %7d %5.1f%% %6.1f\n",
2407 totalnchunks, totalneagerchunks, totalnelems, totalneagerelems, totalnlazyelems,
2408 totalnelems > 0 ? 100.0 * (
double) (totalneagerelems + totalnlazyelems) / (
double) (totalnelems) : 0.0,
2409 (
double)allocedmem/(1024.0*1024.0));
2412 nblocks + nunusedblocks, nunusedblocks, allocedmem, freemem);
2413 if( allocedmem > 0 )
2414 printInfo(
" (%.1f%%)", 100.0 * (
double) freemem / (
double) allocedmem);
2417 printInfo(
"Memory Peaks: Used Lazy Total\n");
2418 printInfo(
" %6.1f %6.1f %6.1f MBytes\n", (
double)blkmem->maxmemused / (1024.0 * 1024.0),
2419 (
double)blkmem->maxmemunused / (1024.0 * 1024.0), (
double)blkmem->maxmemallocated / (1024.0 * 1024.0));
2428 long long allocedmem = 0;
2429 long long freemem = 0;
2432 assert(blkmem !=
NULL);
2436 chkmem = blkmem->chkmemhash[i];
2437 while( chkmem !=
NULL )
2441 int neagerelems = 0;
2445 assert(chunk != NULL);
2446 assert(chunk->elemsize == chkmem->elemsize);
2447 assert(chunk->chkmem == chkmem);
2449 nelems += chunk->storesize;
2450 if( chunk->eagerfree != NULL )
2451 neagerelems += chunk->eagerfreesize;
2454 assert(nchunks == chkmem->nchunks);
2456 assert(nelems == chkmem->storesize);
2457 assert(neagerelems == chkmem->eagerfreesize);
2461 allocedmem += (
long long)chkmem->elemsize * (
long long)nelems;
2462 freemem += (
long long)chkmem->elemsize * ((
long long)neagerelems + (
long long)chkmem->lazyfreesize);
2464 if( nelems != neagerelems + chkmem->lazyfreesize )
2468 (((
long long)nelems - (
long long)neagerelems) - (
long long)chkmem->lazyfreesize)
2469 * (
long long)(chkmem->elemsize),
2470 (nelems - neagerelems) - chkmem->lazyfreesize, (
long long)(chkmem->elemsize),
2471 chkmem->filename, chkmem->line);
2473 errorMessage(
"%" LONGINT_FORMAT
" bytes (%d elements of size %" LONGINT_FORMAT
") not freed.\n",
2474 ((nelems - neagerelems) - chkmem->lazyfreesize) * (
long long)(chkmem->elemsize),
2475 (nelems - neagerelems) - chkmem->lazyfreesize, (
long long)(chkmem->elemsize));
2479 chkmem = chkmem->nextchkmem;
2483 if( allocedmem != freemem )
2488 return allocedmem - freemem;
2519 double arraygrowfac,
2522 const char* filename,
2528 assert( arraygrowinit > 0 );
2529 assert( arraygrowfac > 0.0 );
2532 if ( buffer !=
NULL )
2538 buffer->
clean = clean;
2547 printError(
"Insufficient memory for buffer memory header.\n");
2556 const char* filename,
2562 if ( *buffer !=
NULL )
2564 i = (*buffer)->ndata;
2568 assert( ! (*buffer)->used[i] );
2582 printError(
"Tried to free null buffer memory.\n");
2592 assert( buffer !=
NULL );
2593 assert( arraygrowfac > 0.0 );
2604 assert( buffer !=
NULL );
2605 assert( arraygrowinit > 0 );
2610 #ifndef SCIP_NOBUFFERMEM 2624 assert( growfac >= 1.0 );
2626 if ( growfac == 1.0 )
2627 size =
MAX(initsize, num);
2633 initsize =
MAX(initsize, 4);
2638 while ( size < num && size > oldsize )
2641 size = (size_t)(growfac * size + initsize);
2645 if ( size <= oldsize )
2649 assert( size >= initsize );
2650 assert( size >= num );
2661 const char* filename,
2667 #ifndef SCIP_NOBUFFERMEM 2671 #ifndef SCIP_NOBUFFERMEM 2672 assert( buffer !=
NULL );
2691 printError(
"Insufficient memory for reallocating buffer data storage.\n");
2698 printError(
"Insufficient memory for reallocating buffer size storage.\n");
2705 printError(
"Insufficient memory for reallocating buffer used storage.\n");
2710 for (i = buffer->
ndata; i < newsize; ++i)
2713 buffer->
size[i] = 0;
2716 buffer->
ndata = newsize;
2722 assert( ! buffer->
used[bufnum] );
2723 if ( buffer->
size[bufnum] < size )
2734 char* tmpptr = (
char*)(buffer->
data[bufnum]);
2735 size_t inc = buffer->
size[bufnum] /
sizeof(*tmpptr);
2740 assert( newsize > buffer->
size[bufnum] );
2742 buffer->
size[bufnum] = newsize;
2744 if ( buffer->
data[bufnum] ==
NULL )
2747 printError(
"Insufficient memory for reallocating buffer storage.\n");
2751 assert( buffer->
size[bufnum] >= size );
2753 #ifdef CHECKCLEANBUFFER 2757 char* tmpptr = (
char*)(buffer->
data[bufnum]);
2758 unsigned int inc = buffer->
size[bufnum] /
sizeof(*tmpptr);
2761 while( --tmpptr >= (
char*)(buffer->
data[bufnum]) )
2762 assert(*tmpptr ==
'\0');
2766 ptr = buffer->
data[bufnum];
2770 debugMessage(
"Allocated buffer %llu/%llu at %p of size %llu (required size: %llu) for pointer %p.\n",
2771 (
unsigned long long)bufnum, (
unsigned long long)(buffer->
ndata), buffer->
data[bufnum],
2772 (
unsigned long long)(buffer->
size[bufnum]), (
unsigned long long)size, ptr);
2795 const char* filename,
2816 const char* filename,
2837 const char* filename,
2856 const char* filename,
2861 #ifndef SCIP_NOBUFFERMEM 2865 #ifndef SCIP_NOBUFFERMEM 2866 assert( buffer !=
NULL );
2868 assert(!buffer->
clean);
2881 while ( bufnum > 0 && buffer->
data[bufnum] != ptr )
2885 assert( buffer->
data[bufnum] == newptr );
2886 assert( buffer->
used[bufnum] );
2887 assert( buffer->
size[bufnum] >= 1 );
2890 if ( size > buffer->
size[bufnum] )
2897 assert( newsize > buffer->
size[bufnum] );
2899 buffer->
size[bufnum] = newsize;
2900 if ( buffer->
data[bufnum] ==
NULL )
2903 printError(
"Insufficient memory for reallocating buffer storage.\n");
2906 newptr = buffer->
data[bufnum];
2908 assert( buffer->
size[bufnum] >= size );
2909 assert( newptr == buffer->
data[bufnum] );
2911 debugMessage(
"Reallocated buffer %llu/%llu at %p to size %llu (required size: %llu) for pointer %p.\n",
2912 (
unsigned long long)bufnum, (
unsigned long long)(buffer->
ndata), buffer->
data[bufnum],
2913 (
unsigned long long)(buffer->
size[bufnum]), (
unsigned long long)size, newptr);
2928 const char* filename,
2950 const char* filename,
2971 const char* filename,
2977 assert( source !=
NULL );
2995 const char* filename,
3001 assert( source !=
NULL );
3018 const char* filename,
3024 assert( buffer !=
NULL );
3027 assert( ptr !=
NULL );
3028 assert( *ptr !=
NULL );
3035 while ( bufnum > 0 && buffer->
data[bufnum] != *ptr )
3038 #ifdef CHECKBUFFERORDER 3039 if ( bufnum < buffer->firstfree - 1 )
3041 warningMessage(
"[%s:%d]: freeing buffer in wrong order.\n", filename, line);
3046 if ( bufnum == 0 && buffer->
data[bufnum] != *ptr )
3049 printError(
"Tried to free unknown buffer pointer.\n");
3052 if ( ! buffer->
used[bufnum] )
3055 printError(
"Tried to free buffer pointer already freed.\n");
3060 #ifdef CHECKCLEANBUFFER 3065 uint8_t* tmpptr = (uint8_t*)(buffer->
data[bufnum]);
3067 for( i = 0; i < buffer->
size[bufnum]; ++i )
3068 assert(tmpptr[i] == 0);
3072 assert( buffer->
data[bufnum] == *ptr );
3078 debugMessage(
"Freed buffer %llu/%llu at %p of size %llu for pointer %p, first free is %llu.\n",
3079 (
unsigned long long)bufnum, (
unsigned long long)(buffer->
ndata), buffer->
data[bufnum],
3080 (
unsigned long long)(buffer->
size[bufnum]), *ptr, (
unsigned long long)(buffer->
firstfree));
3089 const char* filename,
3093 assert( ptr !=
NULL );
3095 #ifndef SCIP_NOBUFFERMEM 3101 printError(
"Tried to free null buffer pointer.\n");
3112 const char* filename,
3116 assert( ptr !=
NULL );
3120 #ifndef SCIP_NOBUFFERMEM 3133 assert( buffer !=
NULL );
3144 size_t totalmem = 0UL;
3147 assert( buffer !=
NULL );
3148 for (i = 0; i < buffer->
ndata; ++i)
3149 totalmem += buffer->
size[i];
3150 assert( totalmem == buffer->
totalmem );
3153 return (
long long) buffer->
totalmem;
3164 assert( buffer !=
NULL );
3167 for (i = 0; i < buffer->
ndata; ++i)
3169 printf(
"[%c] %8llu bytes at %p\n", buffer->
used[i] ?
'*' :
' ', (
unsigned long long)(buffer->
size[i]), buffer->
data[i]);
3170 totalmem += buffer->
size[i];
3172 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 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)
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