28 #define __STDC_LIMIT_MACROS 39 #ifndef NO_CONFIG_HEADER 40 #include "scip/config.h" 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,
1906 const char* filename,
1927 const char* filename,
1946 const char* filename,
1954 assert(oldsize == 0);
1967 alignSize(&oldsize);
1968 alignSize(&newsize);
1969 if( oldsize == newsize )
1973 if( newptr !=
NULL )
1987 const char* filename,
1995 assert(oldnum == 0);
2008 if ( oldnum == newnum )
2012 if ( newptr !=
NULL )
2024 const char* filename,
2030 assert(source !=
NULL);
2045 const char* filename,
2051 assert(source !=
NULL);
2066 const char* filename,
2073 assert(ptr !=
NULL);
2074 assert(*ptr !=
NULL);
2080 debugMessage(
"free %8llu bytes in %p [%s:%d]\n", (
unsigned long long)size, *ptr, filename, line);
2083 assert( blkmem->chkmemhash !=
NULL );
2084 chkmem = blkmem->chkmemhash[hashnumber];
2085 while( chkmem !=
NULL && chkmem->elemsize != (
int)size )
2086 chkmem = chkmem->nextchkmem;
2087 if( chkmem ==
NULL )
2090 printError(
"Tried to free pointer <%p> in block memory <%p> of unknown size %llu.\n", *ptr, (
void*)blkmem, (
unsigned long long)size);
2093 assert(chkmem->elemsize == (
int)size);
2097 blkmem->memused -= (
long long) size;
2099 blkmem->maxmemunused =
MAX(blkmem->maxmemunused, blkmem->memallocated - blkmem->memused);
2101 assert(blkmem->memused >= 0);
2102 assert(blkmem->memallocated >= 0);
2114 const char* filename,
2118 assert( blkmem !=
NULL );
2119 assert( ptr !=
NULL );
2123 else if( size != 0 )
2126 printError(
"Tried to free null block pointer.\n");
2136 const char* filename,
2140 assert( blkmem !=
NULL );
2141 assert( ptr !=
NULL );
2159 assert(blkmem !=
NULL);
2165 chkmemptr = &blkmem->chkmemhash[i];
2166 while( *chkmemptr !=
NULL )
2170 if( (*chkmemptr)->nchunks == 0 )
2174 assert((*chkmemptr)->lazyfreesize == 0);
2175 nextchkmem = (*chkmemptr)->nextchkmem;
2177 *chkmemptr = nextchkmem;
2181 chkmemptr = &(*chkmemptr)->nextchkmem;
2191 assert( blkmem !=
NULL );
2193 return blkmem->memallocated;
2201 assert( blkmem !=
NULL );
2203 return blkmem->memused;
2211 assert( blkmem !=
NULL );
2213 return blkmem->memallocated - blkmem->memused;
2221 assert( blkmem !=
NULL );
2223 return blkmem->maxmemused;
2231 assert( blkmem !=
NULL );
2233 return blkmem->maxmemunused;
2241 assert( blkmem !=
NULL );
2243 return blkmem->maxmemallocated;
2254 assert(blkmem !=
NULL);
2260 if( chkmem ==
NULL )
2263 return (
size_t)(chkmem->elemsize);
2273 int nunusedblocks = 0;
2274 int totalnchunks = 0;
2275 int totalneagerchunks = 0;
2276 int totalnelems = 0;
2277 int totalneagerelems = 0;
2278 int totalnlazyelems = 0;
2280 int totalngarbagecalls = 0;
2281 int totalngarbagefrees = 0;
2283 long long allocedmem = 0;
2284 long long freemem = 0;
2288 printInfo(
" ElSize #Chunk #Eag #Elems #EagFr #LazFr #GCl #GFr Free MBytes First Allocator\n");
2290 printInfo(
" ElSize #Chunk #Eag #Elems #EagFr #LazFr Free MBytes\n");
2293 assert(blkmem !=
NULL);
2297 chkmem = blkmem->chkmemhash[i];
2298 while( chkmem !=
NULL )
2302 int neagerchunks = 0;
2303 int neagerelems = 0;
2307 assert(chunk != NULL);
2308 assert(chunk->elemsize == chkmem->elemsize);
2309 assert(chunk->chkmem == chkmem);
2311 nelems += chunk->storesize;
2312 if( chunk->eagerfree != NULL )
2315 neagerelems += chunk->eagerfreesize;
2319 assert(nchunks == chkmem->nchunks);
2320 assert(nelems == chkmem->storesize);
2321 assert(neagerelems == chkmem->eagerfreesize);
2326 allocedmem += (
long long)chkmem->elemsize * (
long long)nelems;
2327 freemem += (
long long)chkmem->elemsize * ((
long long)neagerelems + (
long long)chkmem->lazyfreesize);
2330 printInfo(
"%7d %6d %4d %7d %7d %7d %5d %4d %5.1f%% %6.1f %s:%d\n",
2331 chkmem->elemsize, nchunks, neagerchunks, nelems,
2332 neagerelems, chkmem->lazyfreesize, chkmem->ngarbagecalls, chkmem->ngarbagefrees,
2333 100.0 * (
double) (neagerelems + chkmem->lazyfreesize) / (
double) (nelems),
2334 (
double)chkmem->elemsize * nelems / (1024.0*1024.0),
2335 chkmem->filename, chkmem->line);
2337 printInfo(
"%7d %6d %4d %7d %7d %7d %5.1f%% %6.1f\n",
2338 chkmem->elemsize, nchunks, neagerchunks, nelems,
2339 neagerelems, chkmem->lazyfreesize,
2340 100.0 * (
double) (neagerelems + chkmem->lazyfreesize) / (
double) (nelems),
2341 (
double)chkmem->elemsize * nelems / (1024.0*1024.0));
2347 printInfo(
"%7d <unused> %5d %4d %s:%d\n",
2348 chkmem->elemsize, chkmem->ngarbagecalls, chkmem->ngarbagefrees,
2349 chkmem->filename, chkmem->line);
2351 printInfo(
"%7d <unused>\n", chkmem->elemsize);
2355 totalnchunks += nchunks;
2356 totalneagerchunks += neagerchunks;
2357 totalnelems += nelems;
2358 totalneagerelems += neagerelems;
2359 totalnlazyelems += chkmem->lazyfreesize;
2361 totalngarbagecalls += chkmem->ngarbagecalls;
2362 totalngarbagefrees += chkmem->ngarbagefrees;
2364 chkmem = chkmem->nextchkmem;
2368 printInfo(
" Total %6d %4d %7d %7d %7d %5d %4d %5.1f%% %6.1f\n",
2369 totalnchunks, totalneagerchunks, totalnelems, totalneagerelems, totalnlazyelems,
2370 totalngarbagecalls, totalngarbagefrees,
2371 totalnelems > 0 ? 100.0 * (
double) (totalneagerelems + totalnlazyelems) / (
double) (totalnelems) : 0.0,
2372 (
double)allocedmem/(1024.0*1024.0));
2374 printInfo(
" Total %6d %4d %7d %7d %7d %5.1f%% %6.1f\n",
2375 totalnchunks, totalneagerchunks, totalnelems, totalneagerelems, totalnlazyelems,
2376 totalnelems > 0 ? 100.0 * (
double) (totalneagerelems + totalnlazyelems) / (
double) (totalnelems) : 0.0,
2377 (
double)allocedmem/(1024.0*1024.0));
2380 nblocks + nunusedblocks, nunusedblocks, allocedmem, freemem);
2381 if( allocedmem > 0 )
2382 printInfo(
" (%.1f%%)", 100.0 * (
double) freemem / (
double) allocedmem);
2385 printInfo(
"Memory Peaks: Used Lazy Total\n");
2386 printInfo(
" %6.1f %6.1f %6.1f MBytes\n", (
double)blkmem->maxmemused / (1024.0 * 1024.0),
2387 (
double)blkmem->maxmemunused / (1024.0 * 1024.0), (
double)blkmem->maxmemallocated / (1024.0 * 1024.0));
2396 long long allocedmem = 0;
2397 long long freemem = 0;
2400 assert(blkmem !=
NULL);
2404 chkmem = blkmem->chkmemhash[i];
2405 while( chkmem !=
NULL )
2409 int neagerelems = 0;
2413 assert(chunk != NULL);
2414 assert(chunk->elemsize == chkmem->elemsize);
2415 assert(chunk->chkmem == chkmem);
2417 nelems += chunk->storesize;
2418 if( chunk->eagerfree != NULL )
2419 neagerelems += chunk->eagerfreesize;
2422 assert(nchunks == chkmem->nchunks);
2423 assert(nelems == chkmem->storesize);
2424 assert(neagerelems == chkmem->eagerfreesize);
2428 allocedmem += (
long long)chkmem->elemsize * (
long long)nelems;
2429 freemem += (
long long)chkmem->elemsize * ((
long long)neagerelems + (
long long)chkmem->lazyfreesize);
2431 if( nelems != neagerelems + chkmem->lazyfreesize )
2435 (((
long long)nelems - (
long long)neagerelems) - (
long long)chkmem->lazyfreesize)
2436 * (
long long)(chkmem->elemsize),
2437 (nelems - neagerelems) - chkmem->lazyfreesize, (
long long)(chkmem->elemsize),
2438 chkmem->filename, chkmem->line);
2440 errorMessage(
"%" LONGINT_FORMAT
" bytes (%d elements of size %" LONGINT_FORMAT
") not freed.\n",
2441 ((nelems - neagerelems) - chkmem->lazyfreesize) * (
long long)(chkmem->elemsize),
2442 (nelems - neagerelems) - chkmem->lazyfreesize, (
long long)(chkmem->elemsize));
2446 chkmem = chkmem->nextchkmem;
2450 if( allocedmem != freemem )
2455 return allocedmem - freemem;
2486 double arraygrowfac,
2489 const char* filename,
2495 assert( arraygrowinit > 0 );
2496 assert( arraygrowfac > 0.0 );
2499 if ( buffer !=
NULL )
2505 buffer->
clean = clean;
2514 printError(
"Insufficient memory for buffer memory header.\n");
2523 const char* filename,
2529 if ( *buffer !=
NULL )
2531 i = (*buffer)->ndata;
2535 assert( ! (*buffer)->used[i] );
2549 printError(
"Tried to free null buffer memory.\n");
2559 assert( buffer !=
NULL );
2560 assert( arraygrowfac > 0.0 );
2571 assert( buffer !=
NULL );
2572 assert( arraygrowinit > 0 );
2577 #ifndef SCIP_NOBUFFERMEM 2591 assert( growfac >= 1.0 );
2593 if ( growfac == 1.0 )
2594 size =
MAX(initsize, num);
2600 initsize =
MAX(initsize, 4);
2605 while ( size < num && size > oldsize )
2608 size = (size_t)(growfac * size + initsize);
2612 if ( size <= oldsize )
2616 assert( size >= initsize );
2617 assert( size >= num );
2628 const char* filename,
2634 #ifndef SCIP_NOBUFFERMEM 2638 #ifndef SCIP_NOBUFFERMEM 2639 assert( buffer !=
NULL );
2658 printError(
"Insufficient memory for reallocating buffer data storage.\n");
2665 printError(
"Insufficient memory for reallocating buffer size storage.\n");
2672 printError(
"Insufficient memory for reallocating buffer used storage.\n");
2677 for (i = buffer->
ndata; i < newsize; ++i)
2680 buffer->
size[i] = 0;
2683 buffer->
ndata = newsize;
2689 assert( ! buffer->
used[bufnum] );
2690 if ( buffer->
size[bufnum] < size )
2701 char* tmpptr = (
char*)(buffer->
data[bufnum]);
2702 size_t inc = buffer->
size[bufnum] /
sizeof(*tmpptr);
2707 assert( newsize > buffer->
size[bufnum] );
2709 buffer->
size[bufnum] = newsize;
2711 if ( buffer->
data[bufnum] ==
NULL )
2714 printError(
"Insufficient memory for reallocating buffer storage.\n");
2718 assert( buffer->
size[bufnum] >= size );
2720 #ifdef CHECKCLEANBUFFER 2724 char* tmpptr = (
char*)(buffer->
data[bufnum]);
2725 unsigned int inc = buffer->
size[bufnum] /
sizeof(*tmpptr);
2728 while( --tmpptr >= (
char*)(buffer->
data[bufnum]) )
2729 assert(*tmpptr ==
'\0');
2733 ptr = buffer->
data[bufnum];
2737 debugMessage(
"Allocated buffer %llu/%llu at %p of size %llu (required size: %llu) for pointer %p.\n",
2738 (
unsigned long long)bufnum, (
unsigned long long)(buffer->
ndata), buffer->
data[bufnum],
2739 (
unsigned long long)(buffer->
size[bufnum]), (
unsigned long long)size, ptr);
2762 const char* filename,
2783 const char* filename,
2804 const char* filename,
2823 const char* filename,
2828 #ifndef SCIP_NOBUFFERMEM 2832 #ifndef SCIP_NOBUFFERMEM 2833 assert( buffer !=
NULL );
2835 assert(!buffer->
clean);
2848 while ( bufnum > 0 && buffer->
data[bufnum] != ptr )
2852 assert( buffer->
data[bufnum] == newptr );
2853 assert( buffer->
used[bufnum] );
2854 assert( buffer->
size[bufnum] >= 1 );
2857 if ( size > buffer->
size[bufnum] )
2864 assert( newsize > buffer->
size[bufnum] );
2866 buffer->
size[bufnum] = newsize;
2867 if ( buffer->
data[bufnum] ==
NULL )
2870 printError(
"Insufficient memory for reallocating buffer storage.\n");
2873 newptr = buffer->
data[bufnum];
2875 assert( buffer->
size[bufnum] >= size );
2876 assert( newptr == buffer->
data[bufnum] );
2878 debugMessage(
"Reallocated buffer %llu/%llu at %p to size %llu (required size: %llu) for pointer %p.\n",
2879 (
unsigned long long)bufnum, (
unsigned long long)(buffer->
ndata), buffer->
data[bufnum],
2880 (
unsigned long long)(buffer->
size[bufnum]), (
unsigned long long)size, newptr);
2895 const char* filename,
2917 const char* filename,
2938 const char* filename,
2944 assert( source !=
NULL );
2962 const char* filename,
2968 assert( source !=
NULL );
2985 const char* filename,
2991 assert( buffer !=
NULL );
2994 assert( ptr !=
NULL );
2995 assert( *ptr !=
NULL );
3002 while ( bufnum > 0 && buffer->
data[bufnum] != *ptr )
3005 #ifdef CHECKBUFFERORDER 3006 if ( bufnum < buffer->firstfree - 1 )
3008 warningMessage(
"[%s:%d]: freeing buffer in wrong order.\n", filename, line);
3013 if ( bufnum == 0 && buffer->
data[bufnum] != *ptr )
3016 printError(
"Tried to free unkown buffer pointer.\n");
3019 if ( ! buffer->
used[bufnum] )
3022 printError(
"Tried to free buffer pointer already freed.\n");
3027 #ifdef CHECKCLEANBUFFER 3032 uint8_t* tmpptr = (uint8_t*)(buffer->
data[bufnum]);
3034 for( i = 0; i < buffer->
size[bufnum]; ++i )
3035 assert(tmpptr[i] == 0);
3039 assert( buffer->
data[bufnum] == *ptr );
3045 debugMessage(
"Freed buffer %llu/%llu at %p of size %llu for pointer %p, first free is %llu.\n",
3046 (
unsigned long long)bufnum, (
unsigned long long)(buffer->
ndata), buffer->
data[bufnum],
3047 (
unsigned long long)(buffer->
size[bufnum]), *ptr, (
unsigned long long)(buffer->
firstfree));
3056 const char* filename,
3060 assert( ptr !=
NULL );
3062 #ifndef SCIP_NOBUFFERMEM 3068 printError(
"Tried to free null buffer pointer.\n");
3079 const char* filename,
3083 assert( ptr !=
NULL );
3087 #ifndef SCIP_NOBUFFERMEM 3100 assert( buffer !=
NULL );
3111 size_t totalmem = 0UL;
3114 assert( buffer !=
NULL );
3115 for (i = 0; i < buffer->
ndata; ++i)
3116 totalmem += buffer->
size[i];
3117 assert( totalmem == buffer->
totalmem );
3120 return (
long long) buffer->
totalmem;
3131 assert( buffer !=
NULL );
3134 for (i = 0; i < buffer->
ndata; ++i)
3136 printf(
"[%c] %8llu bytes at %p\n", buffer->
used[i] ?
'*' :
' ', (
unsigned long long)(buffer->
size[i]), buffer->
data[i]);
3137 totalmem += buffer->
size[i];
3139 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 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