28 #define __STDC_LIMIT_MACROS 39 #ifndef NO_CONFIG_HEADER 40 #include "scip/config.h" 58 #ifndef SCIP_THREADSAFE 62 #ifdef ENABLE_MEMLIST_CHECKS 78 #ifdef SCIPdebugMessage 79 #define debugMessage SCIPdebugMessage 80 #define errorMessage SCIPerrorMessage 82 #define debugMessage while( FALSE ) printf 83 #define errorMessage printf 84 #define printErrorHeader(f,l) printf("[%s:%d] ERROR: ", f, l) 85 #define printError printf 88 #ifdef ENABLE_MEMLIST_CHECKS 89 #define warningMessage printf 91 #define printInfo printf 99 #define MAX(x,y) ((x) >= (y) ? (x) : (y)) 100 #define MIN(x,y) ((x) <= (y) ? (x) : (y)) 103 #ifndef SCIP_LONGINT_FORMAT 104 #if defined(_WIN32) || defined(_WIN64) 105 #define LONGINT_FORMAT "I64d" 107 #define LONGINT_FORMAT "lld" 110 #define LONGINT_FORMAT SCIP_LONGINT_FORMAT 113 #ifndef SCIP_MAXMEMSIZE 115 #define MAXMEMSIZE SIZE_MAX / 2 117 #define MAXMEMSIZE SCIP_MAXMEMSIZE 122 #if defined(_WIN32) || defined(_WIN64) || defined(__STDC__) 123 #define INLINE __inline 125 #define INLINE inline 136 #if !defined(NDEBUG) && defined(ENABLE_MEMLIST_CHECKS) 138 typedef struct Memlist MEMLIST;
150 static MEMLIST* memlist =
NULL;
151 static size_t memused = 0;
160 MEMLIST* list = memlist;
163 while( list !=
NULL )
168 assert(used == memused);
171 #define checkMemlist() 179 const char* filename,
185 assert(ptr !=
NULL && size > 0);
187 list = (MEMLIST*)malloc(
sizeof(MEMLIST));
188 assert(list !=
NULL);
192 list->filename = strdup(filename);
193 assert(list->filename !=
NULL);
195 list->next = memlist;
205 const char* filename,
216 while( list !=
NULL && ptr != list->ptr )
218 listptr = &(list->next);
223 assert(ptr == list->ptr);
225 *listptr = list->next;
226 assert( list->size <= memused );
227 memused -= list->size;
228 free(list->filename);
234 printError(
"Tried to free unknown pointer <%p>.\n", ptr);
247 while( list !=
NULL && ptr != list->ptr )
265 while( list !=
NULL )
267 printInfo(
"%12p %8llu %s:%d\n", list->ptr, (
unsigned long long) list->size, list->filename, list->line);
271 printInfo(
"Total: %8llu\n", (
unsigned long long) memused);
272 if( used != memused )
274 errorMessage(
"Used memory in list sums up to %llu instead of %llu\n", (
unsigned long long)used, (
unsigned long long)memused);
284 if( memlist !=
NULL || memused > 0 )
286 warningMessage(
"Memory list not empty.\n");
296 return (
long long) memused;
301 #define addMemlistEntry(ptr, size, filename, line) do { (void) (ptr); (void) (size); (void) (filename); (void) (line); } while(0) 302 #define removeMemlistEntry(ptr, filename, line) do { (void) (ptr); (void) (filename); (void) (line); } while(0) 322 printInfo(
"Optimized, threadsafe version of memory shell linked - no memory diagnostics available.\n");
346 const char* filename,
352 assert(typesize > 0);
354 debugMessage(
"calloc %llu elements of %llu bytes [%s:%d]\n", (
unsigned long long)num, (
unsigned long long)typesize,
367 typesize =
MAX(typesize, 1);
368 ptr = calloc(num, typesize);
373 printError(
"Insufficient memory for allocation of %llu bytes.\n", (
unsigned long long)(num) * (typesize));
384 const char* filename,
390 debugMessage(
"malloc %llu bytes [%s:%d]\n", (
unsigned long long)size, filename, line);
407 printError(
"Insufficient memory for allocation of %llu bytes.\n", (
unsigned long long)size);
419 const char* filename,
426 debugMessage(
"malloc %llu elements of %llu bytes [%s:%d]\n",
427 (
unsigned long long)num, (
unsigned long long)typesize, filename, line);
438 size = num * typesize;
445 printError(
"Insufficient memory for allocation of %llu bytes.\n", (
unsigned long long)size);
457 const char* filename,
476 newptr = realloc(ptr, size);
481 printError(
"Insufficient memory for reallocation of %llu bytes.\n", (
unsigned long long)size);
494 const char* filename,
513 size = num * typesize;
515 newptr = realloc(ptr, size);
520 printError(
"Insufficient memory for reallocation of %llu bytes.\n", (
unsigned long long)size);
537 memset(ptr, 0, size);
551 assert(source !=
NULL);
552 memcpy(ptr, source, size);
568 assert(source !=
NULL);
569 memmove(ptr, source, size);
577 const char* filename,
583 assert(source !=
NULL || size == 0);
597 const char* filename,
603 assert(source !=
NULL || num == 0);
615 const char* filename,
619 assert( ptr !=
NULL );
637 const char* filename,
641 assert( ptr !=
NULL );
658 #define CHKHASH_POWER 10 659 #define CHKHASH_SIZE (1<<CHKHASH_POWER) 666 long long memallocated;
667 long long maxmemused;
668 long long maxmemunused;
669 long long maxmemallocated;
686 #define CHUNKLENGTH_MIN 1024 687 #define CHUNKLENGTH_MAX 1048576 688 #define STORESIZE_MAX 8192 689 #define GARBAGE_SIZE 256 690 #define ALIGNMENT (sizeof(FREELIST)) 741 #define CHUNK_LT(ptr,chunk) ptr < chunk->store 742 #define CHUNK_GT(ptr,chunk) ptr >= chunk->storeend 786 assert(chunk !=
NULL);
787 assert(chunk->store <= chunk->storeend);
789 return (ptr >= (
void*)(chunk->store) && ptr < (
void*)(chunk->storeend));
805 assert(chkmem !=
NULL);
808 if( rbTreeFindChunk(chkmem->rootchunk, ptr, &chunk) == 0 )
822 assert(chkmem !=
NULL);
843 assert(chunk !=
NULL);
844 assert(chunk->store !=
NULL);
845 assert(chunk->storeend == (
void*)((
char*)(chunk->store) + chunk->elemsize * chunk->storesize));
846 assert(chunk->chkmem !=
NULL);
847 assert(chunk->chkmem->elemsize == chunk->elemsize);
849 if( chunk->eagerfree ==
NULL )
850 assert(chunk->nexteager ==
NULL && chunk->preveager ==
NULL);
851 else if( chunk->preveager ==
NULL )
852 assert(chunk->chkmem->firsteager == chunk);
854 if( chunk->nexteager !=
NULL )
855 assert(chunk->nexteager->preveager == chunk);
856 if( chunk->preveager !=
NULL )
857 assert(chunk->preveager->nexteager == chunk);
860 eager = chunk->eagerfree;
861 while( eager !=
NULL )
867 assert(chunk->eagerfreesize == eagerfreesize);
882 assert(chkmem !=
NULL);
893 storesize += chunk->storesize;
894 eagerfreesize += chunk->eagerfreesize;
897 assert(chkmem->nchunks == nchunks);
898 assert(chkmem->storesize == storesize);
899 assert(chkmem->eagerfreesize == eagerfreesize);
901 assert(((
unsigned int) (chkmem->eagerfreesize == 0)) ^ ( (
unsigned int) (chkmem->firsteager !=
NULL)));
903 if( chkmem->firsteager !=
NULL )
904 assert(chkmem->firsteager->preveager ==
NULL);
906 lazy = chkmem->lazyfree;
907 while( lazy !=
NULL )
910 assert(chunk !=
NULL);
911 assert(chunk->chkmem == chkmem);
915 assert(chkmem->lazyfreesize == lazyfreesize);
918 #define checkChunk(chunk) 919 #define checkChkmem(chkmem) 935 assert(chkmem !=
NULL);
936 assert(chunk !=
NULL);
937 assert(chunk->store !=
NULL);
939 debugMessage(
"linking chunk %p to chunk block %p [elemsize:%d, %d chunks]\n",
940 (
void*)chunk, (
void*)chkmem, chkmem->elemsize, chkmem->nchunks);
942 pos = rbTreeFindChunk(chkmem->rootchunk, chunk->store, &parent);
948 chkmem->storesize += chunk->storesize;
961 assert(chunk !=
NULL);
962 assert(chunk->eagerfree ==
NULL);
963 assert(chunk->nexteager ==
NULL);
964 assert(chunk->preveager ==
NULL);
966 chkmem = chunk->chkmem;
967 assert(chkmem !=
NULL);
968 assert(chkmem->elemsize == chunk->elemsize);
970 debugMessage(
"unlinking chunk %p from chunk block %p [elemsize:%d, %d chunks]\n",
971 (
void*)chunk, (
void*)chkmem, chkmem->elemsize, chkmem->nchunks);
977 chkmem->storesize -= chunk->storesize;
987 assert(chunk->chkmem == chkmem);
988 assert(chunk->nexteager ==
NULL);
989 assert(chunk->preveager ==
NULL);
991 chunk->nexteager = chkmem->firsteager;
992 chunk->preveager =
NULL;
993 if( chkmem->firsteager !=
NULL )
995 assert(chkmem->firsteager->preveager ==
NULL);
996 chkmem->firsteager->preveager = chunk;
998 chkmem->firsteager = chunk;
1007 assert(chunk !=
NULL);
1008 assert(chunk->eagerfreesize == 0 || chunk->eagerfreesize == chunk->storesize);
1010 if( chunk->nexteager !=
NULL )
1011 chunk->nexteager->preveager = chunk->preveager;
1012 if( chunk->preveager !=
NULL )
1013 chunk->preveager->nexteager = chunk->nexteager;
1016 assert(chunk->chkmem->firsteager == chunk);
1017 chunk->chkmem->firsteager = chunk->nexteager;
1019 chunk->nexteager =
NULL;
1020 chunk->preveager =
NULL;
1021 chunk->eagerfree =
NULL;
1039 assert(chkmem !=
NULL);
1041 debugMessage(
"creating new chunk in chunk block %p [elemsize: %d]\n", (
void*)chkmem, chkmem->elemsize);
1044 if( chkmem->nchunks == 0 )
1045 storesize = chkmem->initchunksize;
1047 storesize = 2 * chkmem->lastchunksize;
1048 assert(storesize > 0);
1052 storesize =
MAX(storesize, 1);
1053 chkmem->lastchunksize = storesize;
1057 assert( chkmem->elemsize < INT_MAX / storesize );
1058 assert(
sizeof(
CHUNK) <
MAXMEMSIZE - (
size_t)(storesize * chkmem->elemsize) );
1060 if( newchunk ==
NULL )
1064 newchunk->store = (
void*) ((
char*) newchunk +
sizeof(
CHUNK));
1065 newchunk->storeend = (
void*) ((
char*) newchunk->store + (ptrdiff_t)storesize * chkmem->elemsize);
1066 newchunk->eagerfree =
NULL;
1067 newchunk->nexteager =
NULL;
1068 newchunk->preveager =
NULL;
1069 newchunk->chkmem = chkmem;
1070 newchunk->elemsize = chkmem->elemsize;
1071 newchunk->storesize = storesize;
1072 newchunk->eagerfreesize = 0;
1074 if( memsize !=
NULL )
1075 (*memsize) += ((
long long)((
long long)
sizeof(
CHUNK) + (
long long)storesize * chkmem->elemsize));
1077 debugMessage(
"allocated new chunk %p: %d elements with size %d\n", (
void*)newchunk, newchunk->storesize, newchunk->elemsize);
1082 for( i = 0; i < newchunk->storesize - 1; ++i )
1084 freelist = (
FREELIST*) newchunk->store + (ptrdiff_t)i * chkmem->elemsize / (ptrdiff_t)
sizeof(
FREELIST*);
1085 freelist->next = (
FREELIST*) newchunk->store + ((ptrdiff_t)i + 1) * chkmem->elemsize / (ptrdiff_t)
sizeof(
FREELIST*);
1088 freelist = (
FREELIST*) newchunk->store + ((ptrdiff_t) newchunk->storesize - 1) * chkmem->elemsize / (ptrdiff_t)
sizeof(
FREELIST*);
1089 freelist->next = chkmem->lazyfree;
1090 chkmem->lazyfree = (
FREELIST*) (newchunk->store);
1091 chkmem->lazyfreesize += newchunk->storesize;
1108 assert(chunk !=
NULL);
1109 assert(*chunk !=
NULL);
1113 if( memsize !=
NULL )
1114 (*memsize) -= ((
long long)
sizeof(
CHUNK) + (
long long)(*chunk)->storesize * (*chunk)->elemsize);
1127 assert(chunk !=
NULL);
1128 assert(*chunk !=
NULL);
1129 assert((*chunk)->store !=
NULL);
1130 assert((*chunk)->eagerfree !=
NULL);
1131 assert((*chunk)->chkmem !=
NULL);
1132 assert((*chunk)->chkmem->rootchunk !=
NULL);
1133 assert((*chunk)->chkmem->firsteager !=
NULL);
1134 assert((*chunk)->eagerfreesize == (*chunk)->storesize);
1136 debugMessage(
"freeing chunk %p of chunk block %p [elemsize: %d]\n", (
void*)*chunk, (
void*)(*chunk)->chkmem, (*chunk)->chkmem->elemsize);
1139 (*chunk)->chkmem->eagerfreesize -= (*chunk)->eagerfreesize;
1140 assert((*chunk)->chkmem->eagerfreesize >= 0);
1160 assert(chunk !=
NULL);
1161 assert(chunk->eagerfree !=
NULL);
1162 assert(chunk->eagerfreesize > 0);
1163 assert(chunk->chkmem !=
NULL);
1165 debugMessage(
"allocating chunk element in chunk %p [elemsize: %d]\n", (
void*)chunk, chunk->chkmem->elemsize);
1168 ptr = chunk->eagerfree;
1169 chunk->eagerfree = ptr->next;
1170 chunk->eagerfreesize--;
1171 chunk->chkmem->eagerfreesize--;
1173 assert((chunk->eagerfreesize == 0 && chunk->eagerfree ==
NULL)
1174 || (chunk->eagerfreesize != 0 && chunk->eagerfree !=
NULL));
1175 assert(chunk->chkmem->eagerfreesize >= 0);
1178 if( chunk->eagerfree ==
NULL )
1180 assert(chunk->eagerfreesize == 0);
1196 assert(chunk !=
NULL);
1197 assert(chunk->chkmem !=
NULL);
1200 debugMessage(
"freeing chunk element %p of chunk %p [elemsize: %d]\n", (
void*)ptr, (
void*)chunk, chunk->chkmem->elemsize);
1203 if( chunk->eagerfree ==
NULL )
1205 assert(chunk->eagerfreesize == 0);
1210 ((
FREELIST*)ptr)->next = chunk->eagerfree;
1212 chunk->eagerfreesize++;
1213 chunk->chkmem->eagerfreesize++;
1234 if( chkmem ==
NULL )
1237 chkmem->lazyfree =
NULL;
1238 chkmem->rootchunk =
NULL;
1239 chkmem->firsteager =
NULL;
1240 chkmem->nextchkmem =
NULL;
1241 chkmem->elemsize = size;
1242 chkmem->nchunks = 0;
1243 chkmem->lastchunksize = 0;
1244 chkmem->storesize = 0;
1245 chkmem->lazyfreesize = 0;
1246 chkmem->eagerfreesize = 0;
1247 chkmem->initchunksize = initchunksize;
1248 chkmem->garbagefactor = garbagefactor;
1250 chkmem->filename =
NULL;
1252 chkmem->ngarbagecalls = 0;
1253 chkmem->ngarbagefrees = 0;
1256 if( memsize !=
NULL )
1269 assert(chkmem !=
NULL);
1274 SCIPrbtreeDelete(&chkmem->rootchunk, chunk);
1275 destroyChunk(&chunk, memsize);
1278 chkmem->lazyfree =
NULL;
1279 chkmem->firsteager =
NULL;
1280 chkmem->nchunks = 0;
1281 chkmem->lastchunksize = 0;
1282 chkmem->storesize = 0;
1283 chkmem->lazyfreesize = 0;
1284 chkmem->eagerfreesize = 0;
1294 assert(chkmem !=
NULL);
1295 assert(*chkmem !=
NULL);
1303 if( memsize !=
NULL )
1304 (*memsize) -= (
long long)(
sizeof(
BMS_CHKMEM));
1318 assert(chkmem !=
NULL);
1321 if( chkmem->lazyfree ==
NULL )
1323 assert(chkmem->lazyfreesize == 0);
1326 if( chkmem->firsteager !=
NULL )
1335 assert(chkmem->lazyfree !=
NULL);
1336 assert(chkmem->lazyfreesize > 0);
1338 ptr = chkmem->lazyfree;
1339 chkmem->lazyfree = ptr->next;
1340 chkmem->lazyfreesize--;
1360 assert(chkmem !=
NULL);
1362 debugMessage(
"garbage collection for chunk block %p [elemsize: %d]\n", (
void*)chkmem, chkmem->elemsize);
1365 if( chkmem->lazyfreesize + chkmem->eagerfreesize == chkmem->storesize )
1372 chkmem->ngarbagecalls++;
1376 while( chkmem->lazyfree !=
NULL )
1379 lazyfree = chkmem->lazyfree;
1380 chkmem->lazyfree = chkmem->lazyfree->next;
1381 chkmem->lazyfreesize--;
1384 chunk =
findChunk(chkmem, (
void*)lazyfree);
1388 errorMessage(
"chunk for lazy free chunk %p not found in chunk block %p\n", (
void*)lazyfree, (
void*)chkmem);
1391 assert(chunk !=
NULL);
1395 assert(chunk->eagerfreesize > 0);
1397 assert(chkmem->lazyfreesize == 0);
1400 chunk = chkmem->firsteager;
1401 while( chunk !=
NULL && chkmem->nchunks > 1 )
1403 nexteager = chunk->nexteager;
1404 if( chunk->eagerfreesize == chunk->storesize )
1407 chkmem->ngarbagefrees++;
1423 const char* filename,
1427 assert(chkmem !=
NULL);
1428 assert(ptr !=
NULL);
1430 #if ( defined(CHECKMEM) || defined(CHECKCHKFREE) ) 1435 printError(
"Pointer %p does not belong to chunk block %p (size: %d).\n", ptr, chkmem, chkmem->elemsize);
1440 ((
FREELIST*)ptr)->next = chkmem->lazyfree;
1442 chkmem->lazyfreesize++;
1445 if( chkmem->garbagefactor >= 0 && chkmem->nchunks > 0 && chkmem->lazyfreesize >=
GARBAGE_SIZE 1446 && chkmem->lazyfreesize + chkmem->eagerfreesize
1447 > chkmem->garbagefactor * (
double)(chkmem->storesize) / (
double)(chkmem->nchunks) )
1461 const char* filename,
1469 if( chkmem ==
NULL )
1472 printError(
"Insufficient memory for chunk block.\n");
1474 debugMessage(
"created chunk memory %p [elemsize: %d]\n", (
void*)chkmem, (
int)size);
1482 const char* filename,
1486 debugMessage(
"clearing chunk memory %p [elemsize: %d]\n", (
void*)chkmem, chkmem->elemsize);
1488 if( chkmem !=
NULL )
1493 printError(
"Tried to clear null chunk block.\n");
1500 const char* filename,
1504 assert(chkmem !=
NULL);
1506 debugMessage(
"destroying chunk memory %p [elemsize: %d]\n", (
void*)*chkmem, (*chkmem)->elemsize);
1508 if( *chkmem !=
NULL )
1513 printError(
"Tried to destroy null chunk block.\n");
1521 const char* filename,
1527 assert(chkmem !=
NULL);
1528 assert((
int)size == chkmem->elemsize);
1535 printError(
"Insufficient memory for new chunk.\n");
1537 debugMessage(
"alloced %8llu bytes in %p [%s:%d]\n", (
unsigned long long)size, (
void*)ptr, filename, line);
1549 const char* filename,
1555 assert(chkmem !=
NULL);
1556 assert(source !=
NULL);
1557 assert((
int)size == chkmem->elemsize);
1571 const char* filename,
1575 assert(chkmem !=
NULL);
1576 assert((
int)size == chkmem->elemsize);
1577 assert( ptr !=
NULL );
1581 debugMessage(
"free %8d bytes in %p [%s:%d]\n", chkmem->elemsize, *ptr, filename, line);
1591 printError(
"Tried to free null chunk pointer.\n");
1600 const char* filename,
1604 assert(chkmem !=
NULL);
1605 assert((
int)size == chkmem->elemsize);
1606 assert( ptr !=
NULL );
1610 debugMessage(
"free %8d bytes in %p [%s:%d]\n", chkmem->elemsize, *ptr, filename, line);
1624 debugMessage(
"garbage collection on chunk memory %p [elemsize: %d]\n", (
void*)chkmem, chkmem->elemsize);
1634 assert(chkmem !=
NULL);
1636 return ((
long long)(chkmem->elemsize) * (
long long)(chkmem->storesize));
1662 long long tmpmemalloc = 0LL;
1663 long long tmpmemused = 0LL;
1666 assert(blkmem !=
NULL);
1667 assert(blkmem->chkmemhash !=
NULL);
1671 chkmem = blkmem->chkmemhash[i];
1672 while( chkmem !=
NULL )
1675 tmpmemalloc += ((chkmem->elemsize * chkmem->storesize) + chkmem->nchunks *
sizeof(
CHUNK) +
sizeof(
BMS_CHKMEM));
1676 tmpmemused += (chkmem->elemsize * (chkmem->storesize - chkmem->eagerfreesize - chkmem->lazyfreesize));
1677 chkmem = chkmem->nextchkmem;
1680 assert(tmpmemalloc == blkmem->memallocated);
1681 assert(tmpmemused == blkmem->memused);
1684 #define checkBlkmem(blkmem) 1702 assert(blkmem !=
NULL);
1707 chkmem = blkmem->chkmemhash[i];
1709 chkmem = chkmem->nextchkmem;
1724 return (
int) (((uint32_t)size * UINT32_C(0x9e3779b9))>>(32-
CHKHASH_POWER));
1732 const char* filename,
1740 if( blkmem !=
NULL )
1743 blkmem->chkmemhash[i] =
NULL;
1744 blkmem->initchunksize = initchunksize;
1745 blkmem->garbagefactor = garbagefactor;
1746 blkmem->memused = 0;
1747 blkmem->memallocated = 0;
1748 blkmem->maxmemused = 0;
1749 blkmem->maxmemunused = 0;
1750 blkmem->maxmemallocated = 0;
1755 printError(
"Insufficient memory for block memory header.\n");
1764 const char* filename,
1772 if( blkmem !=
NULL )
1776 chkmem = blkmem->chkmemhash[i];
1777 while( chkmem !=
NULL )
1779 nextchkmem = chkmem->nextchkmem;
1781 chkmem = nextchkmem;
1783 blkmem->chkmemhash[i] =
NULL;
1785 blkmem->memused = 0;
1786 assert(blkmem->memallocated == 0);
1791 printError(
"Tried to clear null block memory.\n");
1798 const char* filename,
1802 assert(blkmem !=
NULL);
1804 if( *blkmem !=
NULL )
1808 assert(*blkmem ==
NULL);
1813 printError(
"Tried to destroy null block memory.\n");
1822 const char* filename,
1830 assert( blkmem !=
NULL );
1837 chkmemptr = &(blkmem->chkmemhash[hashnumber]);
1838 while( *chkmemptr !=
NULL && (*chkmemptr)->elemsize != (
int)size )
1839 chkmemptr = &((*chkmemptr)->nextchkmem);
1842 if( *chkmemptr ==
NULL )
1844 *chkmemptr =
createChkmem((
int)size, blkmem->initchunksize, blkmem->garbagefactor, &blkmem->memallocated);
1845 if( *chkmemptr ==
NULL )
1848 printError(
"Insufficient memory for chunk block.\n");
1853 (*chkmemptr)->line = line;
1863 printError(
"Insufficient memory for new chunk.\n");
1865 debugMessage(
"alloced %8llu bytes in %p [%s:%d]\n", (
unsigned long long)size, ptr, filename, line);
1868 blkmem->memused += (
long long) size;
1869 blkmem->maxmemused =
MAX(blkmem->maxmemused, blkmem->memused);
1870 blkmem->maxmemunused =
MAX(blkmem->maxmemunused, blkmem->memallocated - blkmem->memused);
1871 blkmem->maxmemallocated =
MAX(blkmem->maxmemallocated, blkmem->memallocated);
1873 assert(blkmem->memused >= 0);
1874 assert(blkmem->memallocated >= 0);
1885 const char* filename,
1905 const char* filename,
1923 const char* filename,
1944 const char* filename,
1963 const char* filename,
1971 assert(oldsize == 0);
1984 alignSize(&oldsize);
1985 alignSize(&newsize);
1986 if( oldsize == newsize )
1990 if( newptr !=
NULL )
2004 const char* filename,
2012 assert(oldnum == 0);
2025 if ( oldnum == newnum )
2029 if ( newptr !=
NULL )
2041 const char* filename,
2047 assert(source !=
NULL);
2062 const char* filename,
2068 assert(source !=
NULL);
2083 const char* filename,
2090 assert(ptr !=
NULL);
2091 assert(*ptr !=
NULL);
2097 debugMessage(
"free %8llu bytes in %p [%s:%d]\n", (
unsigned long long)size, *ptr, filename, line);
2100 assert( blkmem->chkmemhash !=
NULL );
2101 chkmem = blkmem->chkmemhash[hashnumber];
2102 while( chkmem !=
NULL && chkmem->elemsize != (
int)size )
2103 chkmem = chkmem->nextchkmem;
2104 if( chkmem ==
NULL )
2107 printError(
"Tried to free pointer <%p> in block memory <%p> of unknown size %llu.\n", *ptr, (
void*)blkmem, (
unsigned long long)size);
2110 assert(chkmem->elemsize == (
int)size);
2114 blkmem->memused -= (
long long) size;
2116 blkmem->maxmemunused =
MAX(blkmem->maxmemunused, blkmem->memallocated - blkmem->memused);
2118 assert(blkmem->memused >= 0);
2119 assert(blkmem->memallocated >= 0);
2131 const char* filename,
2135 assert( blkmem !=
NULL );
2136 assert( ptr !=
NULL );
2140 else if( size != 0 )
2143 printError(
"Tried to free null block pointer.\n");
2153 const char* filename,
2157 assert( blkmem !=
NULL );
2158 assert( ptr !=
NULL );
2176 assert(blkmem !=
NULL);
2182 chkmemptr = &blkmem->chkmemhash[i];
2183 while( *chkmemptr !=
NULL )
2187 if( (*chkmemptr)->nchunks == 0 )
2191 assert((*chkmemptr)->lazyfreesize == 0);
2192 nextchkmem = (*chkmemptr)->nextchkmem;
2194 *chkmemptr = nextchkmem;
2198 chkmemptr = &(*chkmemptr)->nextchkmem;
2208 assert( blkmem !=
NULL );
2210 return blkmem->memallocated;
2218 assert( blkmem !=
NULL );
2220 return blkmem->memused;
2228 assert( blkmem !=
NULL );
2230 return blkmem->memallocated - blkmem->memused;
2238 assert( blkmem !=
NULL );
2240 return blkmem->maxmemused;
2248 assert( blkmem !=
NULL );
2250 return blkmem->maxmemunused;
2258 assert( blkmem !=
NULL );
2260 return blkmem->maxmemallocated;
2271 assert(blkmem !=
NULL);
2277 if( chkmem ==
NULL )
2280 return (
size_t)(chkmem->elemsize);
2290 int nunusedblocks = 0;
2291 int totalnchunks = 0;
2292 int totalneagerchunks = 0;
2293 int totalnelems = 0;
2294 int totalneagerelems = 0;
2295 int totalnlazyelems = 0;
2297 int totalngarbagecalls = 0;
2298 int totalngarbagefrees = 0;
2300 long long allocedmem = 0;
2301 long long freemem = 0;
2305 printInfo(
" ElSize #Chunk #Eag #Elems #EagFr #LazFr #GCl #GFr Free MBytes First Allocator\n");
2307 printInfo(
" ElSize #Chunk #Eag #Elems #EagFr #LazFr Free MBytes\n");
2310 assert(blkmem !=
NULL);
2314 chkmem = blkmem->chkmemhash[i];
2315 while( chkmem !=
NULL )
2319 int neagerchunks = 0;
2320 int neagerelems = 0;
2324 assert(chunk != NULL);
2325 assert(chunk->elemsize == chkmem->elemsize);
2326 assert(chunk->chkmem == chkmem);
2328 nelems += chunk->storesize;
2329 if( chunk->eagerfree != NULL )
2332 neagerelems += chunk->eagerfreesize;
2336 assert(nchunks == chkmem->nchunks);
2337 assert(nelems == chkmem->storesize);
2338 assert(neagerelems == chkmem->eagerfreesize);
2343 allocedmem += (
long long)chkmem->elemsize * (
long long)nelems;
2344 freemem += (
long long)chkmem->elemsize * ((
long long)neagerelems + (
long long)chkmem->lazyfreesize);
2347 printInfo(
"%7d %6d %4d %7d %7d %7d %5d %4d %5.1f%% %6.1f %s:%d\n",
2348 chkmem->elemsize, nchunks, neagerchunks, nelems,
2349 neagerelems, chkmem->lazyfreesize, chkmem->ngarbagecalls, chkmem->ngarbagefrees,
2350 100.0 * (
double) (neagerelems + chkmem->lazyfreesize) / (
double) (nelems),
2351 (
double)chkmem->elemsize * nelems / (1024.0*1024.0),
2352 chkmem->filename, chkmem->line);
2354 printInfo(
"%7d %6d %4d %7d %7d %7d %5.1f%% %6.1f\n",
2355 chkmem->elemsize, nchunks, neagerchunks, nelems,
2356 neagerelems, chkmem->lazyfreesize,
2357 100.0 * (
double) (neagerelems + chkmem->lazyfreesize) / (
double) (nelems),
2358 (
double)chkmem->elemsize * nelems / (1024.0*1024.0));
2364 printInfo(
"%7d <unused> %5d %4d %s:%d\n",
2365 chkmem->elemsize, chkmem->ngarbagecalls, chkmem->ngarbagefrees,
2366 chkmem->filename, chkmem->line);
2368 printInfo(
"%7d <unused>\n", chkmem->elemsize);
2372 totalnchunks += nchunks;
2373 totalneagerchunks += neagerchunks;
2374 totalnelems += nelems;
2375 totalneagerelems += neagerelems;
2376 totalnlazyelems += chkmem->lazyfreesize;
2378 totalngarbagecalls += chkmem->ngarbagecalls;
2379 totalngarbagefrees += chkmem->ngarbagefrees;
2381 chkmem = chkmem->nextchkmem;
2385 printInfo(
" Total %6d %4d %7d %7d %7d %5d %4d %5.1f%% %6.1f\n",
2386 totalnchunks, totalneagerchunks, totalnelems, totalneagerelems, totalnlazyelems,
2387 totalngarbagecalls, totalngarbagefrees,
2388 totalnelems > 0 ? 100.0 * (
double) (totalneagerelems + totalnlazyelems) / (
double) (totalnelems) : 0.0,
2389 (
double)allocedmem/(1024.0*1024.0));
2391 printInfo(
" Total %6d %4d %7d %7d %7d %5.1f%% %6.1f\n",
2392 totalnchunks, totalneagerchunks, totalnelems, totalneagerelems, totalnlazyelems,
2393 totalnelems > 0 ? 100.0 * (
double) (totalneagerelems + totalnlazyelems) / (
double) (totalnelems) : 0.0,
2394 (
double)allocedmem/(1024.0*1024.0));
2397 nblocks + nunusedblocks, nunusedblocks, allocedmem, freemem);
2398 if( allocedmem > 0 )
2399 printInfo(
" (%.1f%%)", 100.0 * (
double) freemem / (
double) allocedmem);
2402 printInfo(
"Memory Peaks: Used Lazy Total\n");
2403 printInfo(
" %6.1f %6.1f %6.1f MBytes\n", (
double)blkmem->maxmemused / (1024.0 * 1024.0),
2404 (
double)blkmem->maxmemunused / (1024.0 * 1024.0), (
double)blkmem->maxmemallocated / (1024.0 * 1024.0));
2413 long long allocedmem = 0;
2414 long long freemem = 0;
2417 assert(blkmem !=
NULL);
2421 chkmem = blkmem->chkmemhash[i];
2422 while( chkmem !=
NULL )
2426 int neagerelems = 0;
2430 assert(chunk != NULL);
2431 assert(chunk->elemsize == chkmem->elemsize);
2432 assert(chunk->chkmem == chkmem);
2434 nelems += chunk->storesize;
2435 if( chunk->eagerfree != NULL )
2436 neagerelems += chunk->eagerfreesize;
2439 assert(nchunks == chkmem->nchunks);
2440 assert(nelems == chkmem->storesize);
2441 assert(neagerelems == chkmem->eagerfreesize);
2445 allocedmem += (
long long)chkmem->elemsize * (
long long)nelems;
2446 freemem += (
long long)chkmem->elemsize * ((
long long)neagerelems + (
long long)chkmem->lazyfreesize);
2448 if( nelems != neagerelems + chkmem->lazyfreesize )
2452 (((
long long)nelems - (
long long)neagerelems) - (
long long)chkmem->lazyfreesize)
2453 * (
long long)(chkmem->elemsize),
2454 (nelems - neagerelems) - chkmem->lazyfreesize, (
long long)(chkmem->elemsize),
2455 chkmem->filename, chkmem->line);
2457 errorMessage(
"%" LONGINT_FORMAT
" bytes (%d elements of size %" LONGINT_FORMAT
") not freed.\n",
2458 ((nelems - neagerelems) - chkmem->lazyfreesize) * (
long long)(chkmem->elemsize),
2459 (nelems - neagerelems) - chkmem->lazyfreesize, (
long long)(chkmem->elemsize));
2463 chkmem = chkmem->nextchkmem;
2467 if( allocedmem != freemem )
2472 return allocedmem - freemem;
2503 double arraygrowfac,
2506 const char* filename,
2512 assert( arraygrowinit > 0 );
2513 assert( arraygrowfac > 0.0 );
2516 if ( buffer !=
NULL )
2522 buffer->
clean = clean;
2531 printError(
"Insufficient memory for buffer memory header.\n");
2540 const char* filename,
2546 if ( *buffer !=
NULL )
2548 i = (*buffer)->ndata;
2552 assert( ! (*buffer)->used[i] );
2566 printError(
"Tried to free null buffer memory.\n");
2576 assert( buffer !=
NULL );
2577 assert( arraygrowfac > 0.0 );
2588 assert( buffer !=
NULL );
2589 assert( arraygrowinit > 0 );
2594 #ifndef SCIP_NOBUFFERMEM 2608 assert( growfac >= 1.0 );
2610 if ( growfac == 1.0 )
2611 size =
MAX(initsize, num);
2617 initsize =
MAX(initsize, 4);
2622 while ( size < num && size > oldsize )
2625 size = (size_t)(growfac * size + initsize);
2629 if ( size <= oldsize )
2633 assert( size >= initsize );
2634 assert( size >= num );
2645 const char* filename,
2651 #ifndef SCIP_NOBUFFERMEM 2655 #ifndef SCIP_NOBUFFERMEM 2656 assert( buffer !=
NULL );
2675 printError(
"Insufficient memory for reallocating buffer data storage.\n");
2682 printError(
"Insufficient memory for reallocating buffer size storage.\n");
2689 printError(
"Insufficient memory for reallocating buffer used storage.\n");
2694 for (i = buffer->
ndata; i < newsize; ++i)
2697 buffer->
size[i] = 0;
2700 buffer->
ndata = newsize;
2706 assert( ! buffer->
used[bufnum] );
2707 if ( buffer->
size[bufnum] < size )
2718 char* tmpptr = (
char*)(buffer->
data[bufnum]);
2719 size_t inc = buffer->
size[bufnum] /
sizeof(*tmpptr);
2724 assert( newsize > buffer->
size[bufnum] );
2726 buffer->
size[bufnum] = newsize;
2728 if ( buffer->
data[bufnum] ==
NULL )
2731 printError(
"Insufficient memory for reallocating buffer storage.\n");
2735 assert( buffer->
size[bufnum] >= size );
2737 #ifdef CHECKCLEANBUFFER 2741 char* tmpptr = (
char*)(buffer->
data[bufnum]);
2742 unsigned int inc = buffer->
size[bufnum] /
sizeof(*tmpptr);
2745 while( --tmpptr >= (
char*)(buffer->
data[bufnum]) )
2746 assert(*tmpptr ==
'\0');
2750 ptr = buffer->
data[bufnum];
2754 debugMessage(
"Allocated buffer %llu/%llu at %p of size %llu (required size: %llu) for pointer %p.\n",
2755 (
unsigned long long)bufnum, (
unsigned long long)(buffer->
ndata), buffer->
data[bufnum],
2756 (
unsigned long long)(buffer->
size[bufnum]), (
unsigned long long)size, ptr);
2779 const char* filename,
2800 const char* filename,
2821 const char* filename,
2840 const char* filename,
2845 #ifndef SCIP_NOBUFFERMEM 2849 #ifndef SCIP_NOBUFFERMEM 2850 assert( buffer !=
NULL );
2852 assert(!buffer->
clean);
2865 while ( bufnum > 0 && buffer->
data[bufnum] != ptr )
2869 assert( buffer->
data[bufnum] == newptr );
2870 assert( buffer->
used[bufnum] );
2871 assert( buffer->
size[bufnum] >= 1 );
2874 if ( size > buffer->
size[bufnum] )
2881 assert( newsize > buffer->
size[bufnum] );
2883 buffer->
size[bufnum] = newsize;
2884 if ( buffer->
data[bufnum] ==
NULL )
2887 printError(
"Insufficient memory for reallocating buffer storage.\n");
2890 newptr = buffer->
data[bufnum];
2892 assert( buffer->
size[bufnum] >= size );
2893 assert( newptr == buffer->
data[bufnum] );
2895 debugMessage(
"Reallocated buffer %llu/%llu at %p to size %llu (required size: %llu) for pointer %p.\n",
2896 (
unsigned long long)bufnum, (
unsigned long long)(buffer->
ndata), buffer->
data[bufnum],
2897 (
unsigned long long)(buffer->
size[bufnum]), (
unsigned long long)size, newptr);
2912 const char* filename,
2934 const char* filename,
2955 const char* filename,
2961 assert( source !=
NULL );
2979 const char* filename,
2985 assert( source !=
NULL );
3002 const char* filename,
3008 assert( buffer !=
NULL );
3011 assert( ptr !=
NULL );
3012 assert( *ptr !=
NULL );
3019 while ( bufnum > 0 && buffer->
data[bufnum] != *ptr )
3022 #ifdef CHECKBUFFERORDER 3023 if ( bufnum < buffer->firstfree - 1 )
3025 warningMessage(
"[%s:%d]: freeing buffer in wrong order.\n", filename, line);
3030 if ( bufnum == 0 && buffer->
data[bufnum] != *ptr )
3033 printError(
"Tried to free unkown buffer pointer.\n");
3036 if ( ! buffer->
used[bufnum] )
3039 printError(
"Tried to free buffer pointer already freed.\n");
3044 #ifdef CHECKCLEANBUFFER 3049 uint8_t* tmpptr = (uint8_t*)(buffer->
data[bufnum]);
3051 for( i = 0; i < buffer->
size[bufnum]; ++i )
3052 assert(tmpptr[i] == 0);
3056 assert( buffer->
data[bufnum] == *ptr );
3062 debugMessage(
"Freed buffer %llu/%llu at %p of size %llu for pointer %p, first free is %llu.\n",
3063 (
unsigned long long)bufnum, (
unsigned long long)(buffer->
ndata), buffer->
data[bufnum],
3064 (
unsigned long long)(buffer->
size[bufnum]), *ptr, (
unsigned long long)(buffer->
firstfree));
3073 const char* filename,
3077 assert( ptr !=
NULL );
3079 #ifndef SCIP_NOBUFFERMEM 3085 printError(
"Tried to free null buffer pointer.\n");
3096 const char* filename,
3100 assert( ptr !=
NULL );
3104 #ifndef SCIP_NOBUFFERMEM 3117 assert( buffer !=
NULL );
3128 size_t totalmem = 0UL;
3131 assert( buffer !=
NULL );
3132 for (i = 0; i < buffer->
ndata; ++i)
3133 totalmem += buffer->
size[i];
3134 assert( totalmem == buffer->
totalmem );
3137 return (
long long) buffer->
totalmem;
3148 assert( buffer !=
NULL );
3151 for (i = 0; i < buffer->
ndata; ++i)
3153 printf(
"[%c] %8llu bytes at %p\n", buffer->
used[i] ?
'*' :
' ', (
unsigned long long)(buffer->
size[i]), buffer->
data[i]);
3154 totalmem += buffer->
size[i];
3156 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