27 #define __STDC_LIMIT_MACROS 56 #ifdef SCIPdebugMessage 57 #define debugMessage SCIPdebugMessage 58 #define errorMessage SCIPerrorMessage 60 #define debugMessage while( FALSE ) printf 61 #define errorMessage printf 62 #define printErrorHeader(f,l) printf("[%s:%d] ERROR: ", f, l) 63 #define printError printf 66 #define warningMessage printf 67 #define printInfo printf 75 #define MAX(x,y) ((x) >= (y) ? (x) : (y)) 76 #define MIN(x,y) ((x) <= (y) ? (x) : (y)) 79 #ifndef SCIP_LONGINT_FORMAT 80 #if defined(_WIN32) || defined(_WIN64) 81 #define LONGINT_FORMAT "I64d" 83 #define LONGINT_FORMAT "lld" 86 #define LONGINT_FORMAT SCIP_LONGINT_FORMAT 89 #ifndef SCIP_MAXMEMSIZE 91 #define MAXMEMSIZE SIZE_MAX / 2 93 #define MAXMEMSIZE SCIP_MAXMEMSIZE 98 #if defined(_WIN32) || defined(_WIN64) || defined(__STDC__) 99 #define INLINE __inline 101 #define INLINE inline 112 #if !defined(NDEBUG) && defined(NPARASCIP) 114 typedef struct Memlist MEMLIST;
126 static MEMLIST* memlist = NULL;
127 static size_t memused = 0;
136 MEMLIST* list = memlist;
139 while( list != NULL )
144 assert(used == memused);
147 #define checkMemlist() 152 void addMemlistEntry(
155 const char* filename,
161 assert(ptr != NULL && size > 0);
163 list = (MEMLIST*)malloc(
sizeof(MEMLIST));
164 assert(list != NULL);
168 list->filename = strdup(filename);
169 assert(list->filename != NULL);
171 list->next = memlist;
179 void removeMemlistEntry(
181 const char* filename,
192 while( list != NULL && ptr != list->ptr )
194 listptr = &(list->next);
199 assert(ptr == list->ptr);
201 *listptr = list->next;
202 assert( list->size <= memused );
203 memused -= list->size;
204 free(list->filename);
210 printError(
"Tried to free unknown pointer <%p>.\n", ptr);
223 while( list != NULL && ptr != list->ptr )
241 while( list != NULL )
243 printInfo(
"%12p %8llu %s:%d\n", list->ptr, (
unsigned long long) list->size, list->filename, list->line);
247 printInfo(
"Total: %8llu\n", (
unsigned long long) memused);
248 if( used != memused )
250 errorMessage(
"Used memory in list sums up to %llu instead of %llu\n", (
unsigned long long)used, (
unsigned long long)memused);
260 if( memlist != NULL || memused > 0 )
272 return (
long long) memused;
295 printInfo(
"Optimized version of memory shell linked - no memory diagnostics available.\n");
305 printInfo(
"Optimized version of memory shell linked - no memory leakage check available.\n");
323 const char* filename,
329 assert(typesize > 0);
331 debugMessage(
"calloc %llu elements of %llu bytes [%s:%d]\n", (
unsigned long long)num, (
unsigned long long)typesize,
344 typesize =
MAX(typesize, 1);
345 ptr = calloc(num, typesize);
350 printError(
"Insufficient memory for allocation of %llu bytes.\n", (
unsigned long long)(num) * (typesize));
352 #if !defined(NDEBUG) && defined(NPARASCIP) 354 addMemlistEntry(ptr, num*typesize, filename, line);
363 const char* filename,
369 debugMessage(
"malloc %llu bytes [%s:%d]\n", (
unsigned long long)size, filename, line);
386 printError(
"Insufficient memory for allocation of %llu bytes.\n", (
unsigned long long)size);
388 #if !defined(NDEBUG) && defined(NPARASCIP) 390 addMemlistEntry(ptr, size, filename, line);
400 const char* filename,
407 debugMessage(
"malloc %llu elements of %llu bytes [%s:%d]\n",
408 (
unsigned long long)num, (
unsigned long long)typesize, filename, line);
419 size = num * typesize;
426 printError(
"Insufficient memory for allocation of %llu bytes.\n", (
unsigned long long)size);
428 #if !defined(NDEBUG) && defined(NPARASCIP) 430 addMemlistEntry(ptr, size, filename, line);
440 const char* filename,
446 #if !defined(NDEBUG) && defined(NPARASCIP) 448 removeMemlistEntry(ptr, filename, line);
461 newptr = realloc(ptr, size);
466 printError(
"Insufficient memory for reallocation of %llu bytes.\n", (
unsigned long long)size);
468 #if !defined(NDEBUG) && defined(NPARASCIP) 470 addMemlistEntry(newptr, size, filename, line);
481 const char* filename,
488 #if !defined(NDEBUG) && defined(NPARASCIP) 490 removeMemlistEntry(ptr, filename, line);
502 size = num * typesize;
504 newptr = realloc(ptr, size);
509 printError(
"Insufficient memory for reallocation of %llu bytes.\n", (
unsigned long long)size);
511 #if !defined(NDEBUG) && defined(NPARASCIP) 513 addMemlistEntry(newptr, size, filename, line);
528 memset(ptr, 0, size);
542 assert(source != NULL);
543 memcpy(ptr, source, size);
559 assert(source != NULL);
560 memmove(ptr, source, size);
568 const char* filename,
574 assert(source != NULL || size == 0);
588 const char* filename,
594 assert(source != NULL || num == 0);
606 const char* filename,
610 assert( ptr != NULL );
613 #if !defined(NDEBUG) && defined(NPARASCIP) 614 removeMemlistEntry(*ptr, filename, line);
629 const char* filename,
633 assert( ptr != NULL );
636 #if !defined(NDEBUG) && defined(NPARASCIP) 637 removeMemlistEntry(*ptr, filename, line);
651 #define CHKHASH_POWER 10 652 #define CHKHASH_SIZE (1<<CHKHASH_POWER) 659 long long memallocated;
660 long long maxmemused;
661 long long maxmemunused;
662 long long maxmemallocated;
679 #define CHUNKLENGTH_MIN 1024 680 #define CHUNKLENGTH_MAX 1048576 681 #define STORESIZE_MAX 8192 682 #define GARBAGE_SIZE 256 683 #define ALIGNMENT (sizeof(FREELIST)) 734 #define CHUNK_LT(ptr,chunk) ptr < chunk->store 735 #define CHUNK_GT(ptr,chunk) ptr >= chunk->storeend 779 assert(chunk != NULL);
780 assert(chunk->store <= chunk->storeend);
782 return (ptr >= (
void*)(chunk->store) && ptr < (
void*)(chunk->storeend));
798 assert(chkmem != NULL);
801 if( rbTreeFindChunk(chkmem->rootchunk, ptr, &chunk) == 0 )
815 assert(chkmem != NULL);
836 assert(chunk != NULL);
837 assert(chunk->store != NULL);
838 assert(chunk->storeend == (
void*)((
char*)(chunk->store) + chunk->elemsize * chunk->storesize));
839 assert(chunk->chkmem != NULL);
840 assert(chunk->chkmem->elemsize == chunk->elemsize);
842 if( chunk->eagerfree == NULL )
843 assert(chunk->nexteager == NULL && chunk->preveager == NULL);
844 else if( chunk->preveager == NULL )
845 assert(chunk->chkmem->firsteager == chunk);
847 if( chunk->nexteager != NULL )
848 assert(chunk->nexteager->preveager == chunk);
849 if( chunk->preveager != NULL )
850 assert(chunk->preveager->nexteager == chunk);
853 eager = chunk->eagerfree;
854 while( eager != NULL )
860 assert(chunk->eagerfreesize == eagerfreesize);
875 assert(chkmem != NULL);
886 storesize += chunk->storesize;
887 eagerfreesize += chunk->eagerfreesize;
890 assert(chkmem->nchunks == nchunks);
891 assert(chkmem->storesize == storesize);
892 assert(chkmem->eagerfreesize == eagerfreesize);
894 assert(((
unsigned int) (chkmem->eagerfreesize == 0)) ^ ( (
unsigned int) (chkmem->firsteager != NULL)));
896 if( chkmem->firsteager != NULL )
897 assert(chkmem->firsteager->preveager == NULL);
899 lazy = chkmem->lazyfree;
900 while( lazy != NULL )
903 assert(chunk != NULL);
904 assert(chunk->chkmem == chkmem);
908 assert(chkmem->lazyfreesize == lazyfreesize);
911 #define checkChunk(chunk) 912 #define checkChkmem(chkmem) 928 assert(chkmem != NULL);
929 assert(chunk != NULL);
930 assert(chunk->store != NULL);
932 debugMessage(
"linking chunk %p to chunk block %p [elemsize:%d, %d chunks]\n",
933 (
void*)chunk, (
void*)chkmem, chkmem->elemsize, chkmem->nchunks);
935 pos = rbTreeFindChunk(chkmem->rootchunk, chunk->store, &parent);
941 chkmem->storesize += chunk->storesize;
954 assert(chunk != NULL);
955 assert(chunk->eagerfree == NULL);
956 assert(chunk->nexteager == NULL);
957 assert(chunk->preveager == NULL);
959 chkmem = chunk->chkmem;
960 assert(chkmem != NULL);
961 assert(chkmem->elemsize == chunk->elemsize);
963 debugMessage(
"unlinking chunk %p from chunk block %p [elemsize:%d, %d chunks]\n",
964 (
void*)chunk, (
void*)chkmem, chkmem->elemsize, chkmem->nchunks);
970 chkmem->storesize -= chunk->storesize;
980 assert(chunk->chkmem == chkmem);
981 assert(chunk->nexteager == NULL);
982 assert(chunk->preveager == NULL);
984 chunk->nexteager = chkmem->firsteager;
985 chunk->preveager = NULL;
986 if( chkmem->firsteager != NULL )
988 assert(chkmem->firsteager->preveager == NULL);
989 chkmem->firsteager->preveager = chunk;
991 chkmem->firsteager = chunk;
1000 assert(chunk != NULL);
1001 assert(chunk->eagerfreesize == 0 || chunk->eagerfreesize == chunk->storesize);
1003 if( chunk->nexteager != NULL )
1004 chunk->nexteager->preveager = chunk->preveager;
1005 if( chunk->preveager != NULL )
1006 chunk->preveager->nexteager = chunk->nexteager;
1009 assert(chunk->chkmem->firsteager == chunk);
1010 chunk->chkmem->firsteager = chunk->nexteager;
1012 chunk->nexteager = NULL;
1013 chunk->preveager = NULL;
1014 chunk->eagerfree = NULL;
1032 assert(chkmem != NULL);
1034 debugMessage(
"creating new chunk in chunk block %p [elemsize: %d]\n", (
void*)chkmem, chkmem->elemsize);
1037 if( chkmem->nchunks == 0 )
1038 storesize = chkmem->initchunksize;
1040 storesize = 2 * chkmem->lastchunksize;
1041 assert(storesize > 0);
1045 storesize =
MAX(storesize, 1);
1046 chkmem->lastchunksize = storesize;
1050 assert( chkmem->elemsize < INT_MAX / storesize );
1051 assert(
sizeof(
CHUNK) <
MAXMEMSIZE - (
size_t)(storesize * chkmem->elemsize) );
1053 if( newchunk == NULL )
1057 newchunk->store = (
void*) ((
char*) newchunk +
sizeof(
CHUNK));
1058 newchunk->storeend = (
void*) ((
char*) newchunk->store + storesize * chkmem->elemsize);
1059 newchunk->eagerfree = NULL;
1060 newchunk->nexteager = NULL;
1061 newchunk->preveager = NULL;
1062 newchunk->chkmem = chkmem;
1063 newchunk->elemsize = chkmem->elemsize;
1064 newchunk->storesize = storesize;
1065 newchunk->eagerfreesize = 0;
1067 if( memsize != NULL )
1068 (*memsize) += ((
long long)(
sizeof(
CHUNK) + (
long long)storesize * chkmem->elemsize));
1070 debugMessage(
"allocated new chunk %p: %d elements with size %d\n", (
void*)newchunk, newchunk->storesize, newchunk->elemsize);
1075 for( i = 0; i < newchunk->storesize - 1; ++i )
1077 freelist = (
FREELIST*) newchunk->store + i * chkmem->elemsize /
sizeof(
FREELIST*);
1078 freelist->next = (
FREELIST*) newchunk->store + (i + 1) * chkmem->elemsize /
sizeof(
FREELIST*);
1081 freelist = (
FREELIST*) newchunk->store + (newchunk->storesize - 1) * chkmem->elemsize /
sizeof(
FREELIST*);
1082 freelist->next = chkmem->lazyfree;
1083 chkmem->lazyfree = (
FREELIST*) (newchunk->store);
1084 chkmem->lazyfreesize += newchunk->storesize;
1101 assert(chunk != NULL);
1105 if( memsize != NULL )
1106 (*memsize) -= ((
long long)
sizeof(
CHUNK) + (
long long)chunk->storesize * chunk->elemsize);
1119 assert(chunk != NULL);
1120 assert(chunk->store != NULL);
1121 assert(chunk->eagerfree != NULL);
1122 assert(chunk->chkmem != NULL);
1123 assert(chunk->chkmem->rootchunk != NULL);
1124 assert(chunk->chkmem->firsteager != NULL);
1125 assert(chunk->eagerfreesize == chunk->storesize);
1127 debugMessage(
"freeing chunk %p of chunk block %p [elemsize: %d]\n", (
void*)chunk, (
void*)chunk->chkmem, chunk->chkmem->elemsize);
1130 chunk->chkmem->eagerfreesize -= chunk->eagerfreesize;
1131 assert(chunk->chkmem->eagerfreesize >= 0);
1151 assert(chunk != NULL);
1152 assert(chunk->eagerfree != NULL);
1153 assert(chunk->eagerfreesize > 0);
1154 assert(chunk->chkmem != NULL);
1156 debugMessage(
"allocating chunk element in chunk %p [elemsize: %d]\n", (
void*)chunk, chunk->chkmem->elemsize);
1159 ptr = chunk->eagerfree;
1160 chunk->eagerfree = ptr->next;
1161 chunk->eagerfreesize--;
1162 chunk->chkmem->eagerfreesize--;
1164 assert((chunk->eagerfreesize == 0 && chunk->eagerfree == NULL)
1165 || (chunk->eagerfreesize != 0 && chunk->eagerfree != NULL));
1166 assert(chunk->chkmem->eagerfreesize >= 0);
1169 if( chunk->eagerfree == NULL )
1171 assert(chunk->eagerfreesize == 0);
1187 assert(chunk != NULL);
1188 assert(chunk->chkmem != NULL);
1191 debugMessage(
"freeing chunk element %p of chunk %p [elemsize: %d]\n", (
void*)ptr, (
void*)chunk, chunk->chkmem->elemsize);
1194 if( chunk->eagerfree == NULL )
1196 assert(chunk->eagerfreesize == 0);
1201 ((
FREELIST*)ptr)->next = chunk->eagerfree;
1203 chunk->eagerfreesize++;
1204 chunk->chkmem->eagerfreesize++;
1225 if( chkmem == NULL )
1228 chkmem->lazyfree = NULL;
1229 chkmem->rootchunk = NULL;
1230 chkmem->firsteager = NULL;
1231 chkmem->nextchkmem = NULL;
1232 chkmem->elemsize = size;
1233 chkmem->nchunks = 0;
1234 chkmem->lastchunksize = 0;
1235 chkmem->storesize = 0;
1236 chkmem->lazyfreesize = 0;
1237 chkmem->eagerfreesize = 0;
1238 chkmem->initchunksize = initchunksize;
1239 chkmem->garbagefactor = garbagefactor;
1241 chkmem->filename = NULL;
1243 chkmem->ngarbagecalls = 0;
1244 chkmem->ngarbagefrees = 0;
1247 if( memsize != NULL )
1260 assert(chkmem != NULL);
1265 SCIPrbtreeDelete(&chkmem->rootchunk, chunk);
1266 destroyChunk(chunk, memsize);
1269 chkmem->lazyfree = NULL;
1270 chkmem->firsteager = NULL;
1271 chkmem->nchunks = 0;
1272 chkmem->lastchunksize = 0;
1273 chkmem->storesize = 0;
1274 chkmem->lazyfreesize = 0;
1275 chkmem->eagerfreesize = 0;
1285 assert(chkmem != NULL);
1286 assert(*chkmem != NULL);
1294 if( memsize != NULL )
1295 (*memsize) -= (
long long)(
sizeof(
BMS_CHKMEM));
1309 assert(chkmem != NULL);
1312 if( chkmem->lazyfree == NULL )
1314 assert(chkmem->lazyfreesize == 0);
1317 if( chkmem->firsteager != NULL )
1326 assert(chkmem->lazyfree != NULL);
1327 assert(chkmem->lazyfreesize > 0);
1329 ptr = chkmem->lazyfree;
1330 chkmem->lazyfree = ptr->next;
1331 chkmem->lazyfreesize--;
1351 assert(chkmem != NULL);
1353 debugMessage(
"garbage collection for chunk block %p [elemsize: %d]\n", (
void*)chkmem, chkmem->elemsize);
1356 if( chkmem->lazyfreesize + chkmem->eagerfreesize == chkmem->storesize )
1363 chkmem->ngarbagecalls++;
1367 while( chkmem->lazyfree != NULL )
1370 lazyfree = chkmem->lazyfree;
1371 chkmem->lazyfree = chkmem->lazyfree->next;
1372 chkmem->lazyfreesize--;
1375 chunk =
findChunk(chkmem, (
void*)lazyfree);
1379 errorMessage(
"chunk for lazy free chunk %p not found in chunk block %p\n", (
void*)lazyfree, (
void*)chkmem);
1382 assert(chunk != NULL);
1386 assert(chunk->eagerfreesize > 0);
1388 assert(chkmem->lazyfreesize == 0);
1391 chunk = chkmem->firsteager;
1392 while( chunk != NULL && chkmem->nchunks > 1 )
1394 nexteager = chunk->nexteager;
1395 if( chunk->eagerfreesize == chunk->storesize )
1398 chkmem->ngarbagefrees++;
1414 const char* filename,
1418 assert(chkmem != NULL);
1419 assert(ptr != NULL);
1421 #if ( defined(CHECKMEM) || defined(CHECKCHKFREE) ) 1426 printError(
"Pointer %p does not belong to chunk block %p (size: %d).\n", ptr, chkmem, chkmem->elemsize);
1431 ((
FREELIST*)ptr)->next = chkmem->lazyfree;
1433 chkmem->lazyfreesize++;
1436 if( chkmem->garbagefactor >= 0 && chkmem->nchunks > 0 && chkmem->lazyfreesize >=
GARBAGE_SIZE 1437 && chkmem->lazyfreesize + chkmem->eagerfreesize
1438 > chkmem->garbagefactor * (
double)(chkmem->storesize) / (
double)(chkmem->nchunks) )
1452 const char* filename,
1459 chkmem =
createChkmem((
int) size, initchunksize, garbagefactor, NULL);
1460 if( chkmem == NULL )
1463 printError(
"Insufficient memory for chunk block.\n");
1465 debugMessage(
"created chunk memory %p [elemsize: %d]\n", (
void*)chkmem, (
int)size);
1473 const char* filename,
1477 debugMessage(
"clearing chunk memory %p [elemsize: %d]\n", (
void*)chkmem, chkmem->elemsize);
1479 if( chkmem != NULL )
1484 printError(
"Tried to clear null chunk block.\n");
1491 const char* filename,
1495 assert(chkmem != NULL);
1497 debugMessage(
"destroying chunk memory %p [elemsize: %d]\n", (
void*)*chkmem, (*chkmem)->elemsize);
1499 if( *chkmem != NULL )
1504 printError(
"Tried to destroy null chunk block.\n");
1512 const char* filename,
1518 assert(chkmem != NULL);
1519 assert((
int)size == chkmem->elemsize);
1526 printError(
"Insufficient memory for new chunk.\n");
1528 debugMessage(
"alloced %8llu bytes in %p [%s:%d]\n", (
unsigned long long)size, (
void*)ptr, filename, line);
1540 const char* filename,
1546 assert(chkmem != NULL);
1547 assert(source != NULL);
1548 assert((
int)size == chkmem->elemsize);
1562 const char* filename,
1566 assert(chkmem != NULL);
1567 assert((
int)size == chkmem->elemsize);
1568 assert( ptr != NULL );
1572 debugMessage(
"free %8d bytes in %p [%s:%d]\n", chkmem->elemsize, *ptr, filename, line);
1582 printError(
"Tried to free null chunk pointer.\n");
1591 const char* filename,
1595 assert(chkmem != NULL);
1596 assert((
int)size == chkmem->elemsize);
1597 assert( ptr != NULL );
1601 debugMessage(
"free %8d bytes in %p [%s:%d]\n", chkmem->elemsize, *ptr, filename, line);
1615 debugMessage(
"garbage collection on chunk memory %p [elemsize: %d]\n", (
void*)chkmem, chkmem->elemsize);
1625 assert(chkmem != NULL);
1627 return ((
long long)(chkmem->elemsize) * (
long long)(chkmem->storesize));
1653 long long tmpmemalloc = 0LL;
1654 long long tmpmemused = 0LL;
1657 assert(blkmem != NULL);
1658 assert(blkmem->chkmemhash != NULL);
1662 chkmem = blkmem->chkmemhash[i];
1663 while( chkmem != NULL )
1666 tmpmemalloc += ((chkmem->elemsize * chkmem->storesize) + chkmem->nchunks *
sizeof(
CHUNK) +
sizeof(
BMS_CHKMEM));
1667 tmpmemused += (chkmem->elemsize * (chkmem->storesize - chkmem->eagerfreesize - chkmem->lazyfreesize));
1668 chkmem = chkmem->nextchkmem;
1671 assert(tmpmemalloc == blkmem->memallocated);
1672 assert(tmpmemused == blkmem->memused);
1675 #define checkBlkmem(blkmem) 1693 assert(blkmem != NULL);
1698 chkmem = blkmem->chkmemhash[i];
1700 chkmem = chkmem->nextchkmem;
1715 return (
int) (((uint32_t)size * UINT32_C(0x9e3779b9))>>(32-
CHKHASH_POWER));
1723 const char* filename,
1731 if( blkmem != NULL )
1734 blkmem->chkmemhash[i] = NULL;
1735 blkmem->initchunksize = initchunksize;
1736 blkmem->garbagefactor = garbagefactor;
1737 blkmem->memused = 0;
1738 blkmem->memallocated = 0;
1739 blkmem->maxmemused = 0;
1740 blkmem->maxmemunused = 0;
1741 blkmem->maxmemallocated = 0;
1746 printError(
"Insufficient memory for block memory header.\n");
1755 const char* filename,
1763 if( blkmem != NULL )
1767 chkmem = blkmem->chkmemhash[i];
1768 while( chkmem != NULL )
1770 nextchkmem = chkmem->nextchkmem;
1772 chkmem = nextchkmem;
1774 blkmem->chkmemhash[i] = NULL;
1776 blkmem->memused = 0;
1777 assert(blkmem->memallocated == 0);
1782 printError(
"Tried to clear null block memory.\n");
1789 const char* filename,
1793 assert(blkmem != NULL);
1795 if( *blkmem != NULL )
1799 assert(*blkmem == NULL);
1804 printError(
"Tried to destroy null block memory.\n");
1813 const char* filename,
1821 assert( blkmem != NULL );
1828 chkmemptr = &(blkmem->chkmemhash[hashnumber]);
1829 while( *chkmemptr != NULL && (*chkmemptr)->elemsize != (
int)size )
1830 chkmemptr = &((*chkmemptr)->nextchkmem);
1833 if( *chkmemptr == NULL )
1835 *chkmemptr =
createChkmem((
int)size, blkmem->initchunksize, blkmem->garbagefactor, &blkmem->memallocated);
1836 if( *chkmemptr == NULL )
1839 printError(
"Insufficient memory for chunk block.\n");
1844 (*chkmemptr)->line = line;
1854 printError(
"Insufficient memory for new chunk.\n");
1856 debugMessage(
"alloced %8llu bytes in %p [%s:%d]\n", (
unsigned long long)size, ptr, filename, line);
1859 blkmem->memused += (
long long) size;
1860 blkmem->maxmemused =
MAX(blkmem->maxmemused, blkmem->memused);
1861 blkmem->maxmemunused =
MAX(blkmem->maxmemunused, blkmem->memallocated - blkmem->memused);
1862 blkmem->maxmemallocated =
MAX(blkmem->maxmemallocated, blkmem->memallocated);
1864 assert(blkmem->memused >= 0);
1865 assert(blkmem->memallocated >= 0);
1876 const char* filename,
1897 const char* filename,
1918 const char* filename,
1937 const char* filename,
1945 assert(oldsize == 0);
1958 alignSize(&oldsize);
1959 alignSize(&newsize);
1960 if( oldsize == newsize )
1964 if( newptr != NULL )
1978 const char* filename,
1986 assert(oldnum == 0);
1999 if ( oldnum == newnum )
2003 if ( newptr != NULL )
2015 const char* filename,
2021 assert(source != NULL);
2036 const char* filename,
2042 assert(source != NULL);
2057 const char* filename,
2064 assert(ptr != NULL);
2065 assert(*ptr != NULL);
2071 debugMessage(
"free %8llu bytes in %p [%s:%d]\n", (
unsigned long long)size, *ptr, filename, line);
2074 assert( blkmem->chkmemhash != NULL );
2075 chkmem = blkmem->chkmemhash[hashnumber];
2076 while( chkmem != NULL && chkmem->elemsize != (
int)size )
2077 chkmem = chkmem->nextchkmem;
2078 if( chkmem == NULL )
2081 printError(
"Tried to free pointer <%p> in block memory <%p> of unknown size %llu.\n", *ptr, (
void*)blkmem, (
unsigned long long)size);
2084 assert(chkmem->elemsize == (
int)size);
2088 blkmem->memused -= (
long long) size;
2090 blkmem->maxmemunused =
MAX(blkmem->maxmemunused, blkmem->memallocated - blkmem->memused);
2092 assert(blkmem->memused >= 0);
2093 assert(blkmem->memallocated >= 0);
2105 const char* filename,
2109 assert( blkmem != NULL );
2110 assert( ptr != NULL );
2114 else if( size != 0 )
2117 printError(
"Tried to free null block pointer.\n");
2127 const char* filename,
2131 assert( blkmem != NULL );
2132 assert( ptr != NULL );
2150 assert(blkmem != NULL);
2156 chkmemptr = &blkmem->chkmemhash[i];
2157 while( *chkmemptr != NULL )
2161 if( (*chkmemptr)->nchunks == 0 )
2165 assert((*chkmemptr)->lazyfreesize == 0);
2166 nextchkmem = (*chkmemptr)->nextchkmem;
2168 *chkmemptr = nextchkmem;
2172 chkmemptr = &(*chkmemptr)->nextchkmem;
2182 assert( blkmem != NULL );
2184 return blkmem->memallocated;
2192 assert( blkmem != NULL );
2194 return blkmem->memused;
2202 assert( blkmem != NULL );
2204 return blkmem->memallocated - blkmem->memused;
2212 assert( blkmem != NULL );
2214 return blkmem->maxmemused;
2222 assert( blkmem != NULL );
2224 return blkmem->maxmemunused;
2232 assert( blkmem != NULL );
2234 return blkmem->maxmemallocated;
2245 assert(blkmem != NULL);
2251 if( chkmem == NULL )
2254 return (
size_t)(chkmem->elemsize);
2264 int nunusedblocks = 0;
2265 int totalnchunks = 0;
2266 int totalneagerchunks = 0;
2267 int totalnelems = 0;
2268 int totalneagerelems = 0;
2269 int totalnlazyelems = 0;
2271 int totalngarbagecalls = 0;
2272 int totalngarbagefrees = 0;
2274 long long allocedmem = 0;
2275 long long freemem = 0;
2279 printInfo(
" ElSize #Chunk #Eag #Elems #EagFr #LazFr #GCl #GFr Free MBytes First Allocator\n");
2281 printInfo(
" ElSize #Chunk #Eag #Elems #EagFr #LazFr Free MBytes\n");
2284 assert(blkmem != NULL);
2288 chkmem = blkmem->chkmemhash[i];
2289 while( chkmem != NULL )
2293 int neagerchunks = 0;
2294 int neagerelems = 0;
2298 assert(chunk != NULL);
2299 assert(chunk->elemsize == chkmem->elemsize);
2300 assert(chunk->chkmem == chkmem);
2302 nelems += chunk->storesize;
2303 if( chunk->eagerfree != NULL )
2306 neagerelems += chunk->eagerfreesize;
2310 assert(nchunks == chkmem->nchunks);
2311 assert(nelems == chkmem->storesize);
2312 assert(neagerelems == chkmem->eagerfreesize);
2317 allocedmem += (
long long)chkmem->elemsize * (
long long)nelems;
2318 freemem += (
long long)chkmem->elemsize * ((
long long)neagerelems + (
long long)chkmem->lazyfreesize);
2321 printInfo(
"%7d %6d %4d %7d %7d %7d %5d %4d %5.1f%% %6.1f %s:%d\n",
2322 chkmem->elemsize, nchunks, neagerchunks, nelems,
2323 neagerelems, chkmem->lazyfreesize, chkmem->ngarbagecalls, chkmem->ngarbagefrees,
2324 100.0 * (
double) (neagerelems + chkmem->lazyfreesize) / (
double) (nelems),
2325 (
double)chkmem->elemsize * nelems / (1024.0*1024.0),
2326 chkmem->filename, chkmem->line);
2328 printInfo(
"%7d %6d %4d %7d %7d %7d %5.1f%% %6.1f\n",
2329 chkmem->elemsize, nchunks, neagerchunks, nelems,
2330 neagerelems, chkmem->lazyfreesize,
2331 100.0 * (
double) (neagerelems + chkmem->lazyfreesize) / (
double) (nelems),
2332 (
double)chkmem->elemsize * nelems / (1024.0*1024.0));
2338 printInfo(
"%7d <unused> %5d %4d %s:%d\n",
2339 chkmem->elemsize, chkmem->ngarbagecalls, chkmem->ngarbagefrees,
2340 chkmem->filename, chkmem->line);
2342 printInfo(
"%7d <unused>\n", chkmem->elemsize);
2346 totalnchunks += nchunks;
2347 totalneagerchunks += neagerchunks;
2348 totalnelems += nelems;
2349 totalneagerelems += neagerelems;
2350 totalnlazyelems += chkmem->lazyfreesize;
2352 totalngarbagecalls += chkmem->ngarbagecalls;
2353 totalngarbagefrees += chkmem->ngarbagefrees;
2355 chkmem = chkmem->nextchkmem;
2359 printInfo(
" Total %6d %4d %7d %7d %7d %5d %4d %5.1f%% %6.1f\n",
2360 totalnchunks, totalneagerchunks, totalnelems, totalneagerelems, totalnlazyelems,
2361 totalngarbagecalls, totalngarbagefrees,
2362 totalnelems > 0 ? 100.0 * (
double) (totalneagerelems + totalnlazyelems) / (
double) (totalnelems) : 0.0,
2363 (
double)allocedmem/(1024.0*1024.0));
2365 printInfo(
" Total %6d %4d %7d %7d %7d %5.1f%% %6.1f\n",
2366 totalnchunks, totalneagerchunks, totalnelems, totalneagerelems, totalnlazyelems,
2367 totalnelems > 0 ? 100.0 * (
double) (totalneagerelems + totalnlazyelems) / (
double) (totalnelems) : 0.0,
2368 (
double)allocedmem/(1024.0*1024.0));
2371 nblocks + nunusedblocks, nunusedblocks, allocedmem, freemem);
2372 if( allocedmem > 0 )
2373 printInfo(
" (%.1f%%)", 100.0 * (
double) freemem / (
double) allocedmem);
2376 printInfo(
"Memory Peaks: Used Lazy Total\n");
2377 printInfo(
" %6.1f %6.1f %6.1f MBytes\n", (
double)blkmem->maxmemused / (1024.0 * 1024.0),
2378 (
double)blkmem->maxmemunused / (1024.0 * 1024.0), (
double)blkmem->maxmemallocated / (1024.0 * 1024.0));
2387 long long allocedmem = 0;
2388 long long freemem = 0;
2391 assert(blkmem != NULL);
2395 chkmem = blkmem->chkmemhash[i];
2396 while( chkmem != NULL )
2400 int neagerelems = 0;
2404 assert(chunk != NULL);
2405 assert(chunk->elemsize == chkmem->elemsize);
2406 assert(chunk->chkmem == chkmem);
2408 nelems += chunk->storesize;
2409 if( chunk->eagerfree != NULL )
2410 neagerelems += chunk->eagerfreesize;
2413 assert(nchunks == chkmem->nchunks);
2414 assert(nelems == chkmem->storesize);
2415 assert(neagerelems == chkmem->eagerfreesize);
2419 allocedmem += (
long long)chkmem->elemsize * (
long long)nelems;
2420 freemem += (
long long)chkmem->elemsize * ((
long long)neagerelems + (
long long)chkmem->lazyfreesize);
2422 if( nelems != neagerelems + chkmem->lazyfreesize )
2426 (((
long long)nelems - (
long long)neagerelems) - (
long long)chkmem->lazyfreesize)
2427 * (
long long)(chkmem->elemsize),
2428 (nelems - neagerelems) - chkmem->lazyfreesize, (
long long)(chkmem->elemsize),
2429 chkmem->filename, chkmem->line);
2431 errorMessage(
"%" LONGINT_FORMAT
" bytes (%d elements of size %" LONGINT_FORMAT
") not freed.\n",
2432 ((nelems - neagerelems) - chkmem->lazyfreesize) * (
long long)(chkmem->elemsize),
2433 (nelems - neagerelems) - chkmem->lazyfreesize, (
long long)(chkmem->elemsize));
2437 chkmem = chkmem->nextchkmem;
2441 if( allocedmem != freemem )
2446 return allocedmem - freemem;
2477 double arraygrowfac,
2480 const char* filename,
2486 assert( arraygrowinit > 0 );
2487 assert( arraygrowfac > 0.0 );
2490 if ( buffer != NULL )
2492 buffer->
data = NULL;
2493 buffer->
size = NULL;
2494 buffer->
used = NULL;
2496 buffer->
clean = clean;
2505 printError(
"Insufficient memory for buffer memory header.\n");
2514 const char* filename,
2520 if ( *buffer != NULL )
2522 i = (*buffer)->ndata;
2526 assert( ! (*buffer)->used[i] );
2540 printError(
"Tried to free null buffer memory.\n");
2550 assert( buffer != NULL );
2551 assert( arraygrowfac > 0.0 );
2562 assert( buffer != NULL );
2563 assert( arraygrowinit > 0 );
2568 #ifndef SCIP_NOBUFFERMEM 2582 assert( growfac >= 1.0 );
2584 if ( growfac == 1.0 )
2585 size =
MAX(initsize, num);
2591 initsize =
MAX(initsize, 4);
2596 while ( size < num && size > oldsize )
2599 size = (size_t)(growfac * size + initsize);
2603 if ( size <= oldsize )
2607 assert( size >= initsize );
2608 assert( size >= num );
2619 const char* filename,
2625 #ifndef SCIP_NOBUFFERMEM 2629 #ifndef SCIP_NOBUFFERMEM 2630 assert( buffer != NULL );
2646 if ( buffer->
data == NULL )
2649 printError(
"Insufficient memory for reallocating buffer data storage.\n");
2653 if ( buffer->
size == NULL )
2656 printError(
"Insufficient memory for reallocating buffer size storage.\n");
2660 if ( buffer->
used == NULL )
2663 printError(
"Insufficient memory for reallocating buffer used storage.\n");
2668 for (i = buffer->
ndata; i < newsize; ++i)
2670 buffer->
data[i] = NULL;
2671 buffer->
size[i] = 0;
2674 buffer->
ndata = newsize;
2680 assert( ! buffer->
used[bufnum] );
2681 if ( buffer->
size[bufnum] < size )
2692 char* tmpptr = (
char*)(buffer->
data[bufnum]);
2693 size_t inc = buffer->
size[bufnum] /
sizeof(*tmpptr);
2698 assert( newsize > buffer->
size[bufnum] );
2700 buffer->
size[bufnum] = newsize;
2702 if ( buffer->
data[bufnum] == NULL )
2705 printError(
"Insufficient memory for reallocating buffer storage.\n");
2709 assert( buffer->
size[bufnum] >= size );
2715 char* tmpptr = (
char*)(buffer->
data[bufnum]);
2716 unsigned int inc = buffer->
size[bufnum] /
sizeof(*tmpptr);
2719 while( --tmpptr >= (
char*)(buffer->
data[bufnum]) )
2720 assert(*tmpptr ==
'\0');
2724 ptr = buffer->
data[bufnum];
2728 debugMessage(
"Allocated buffer %llu/%llu at %p of size %llu (required size: %llu) for pointer %p.\n",
2729 (
unsigned long long)bufnum, (
unsigned long long)(buffer->
ndata), buffer->
data[bufnum],
2730 (
unsigned long long)(buffer->
size[bufnum]), (
unsigned long long)size, ptr);
2753 const char* filename,
2774 const char* filename,
2795 const char* filename,
2814 const char* filename,
2819 #ifndef SCIP_NOBUFFERMEM 2823 #ifndef SCIP_NOBUFFERMEM 2824 assert( buffer != NULL );
2826 assert(!buffer->
clean);
2839 while ( bufnum > 0 && buffer->
data[bufnum] != ptr )
2843 assert( buffer->
data[bufnum] == newptr );
2844 assert( buffer->
used[bufnum] );
2845 assert( buffer->
size[bufnum] >= 1 );
2848 if ( size > buffer->
size[bufnum] )
2855 assert( newsize > buffer->
size[bufnum] );
2857 buffer->
size[bufnum] = newsize;
2858 if ( buffer->
data[bufnum] == NULL )
2861 printError(
"Insufficient memory for reallocating buffer storage.\n");
2864 newptr = buffer->
data[bufnum];
2866 assert( buffer->
size[bufnum] >= size );
2867 assert( newptr == buffer->
data[bufnum] );
2869 debugMessage(
"Reallocated buffer %llu/%llu at %p to size %llu (required size: %llu) for pointer %p.\n",
2870 (
unsigned long long)bufnum, (
unsigned long long)(buffer->
ndata), buffer->
data[bufnum],
2871 (
unsigned long long)(buffer->
size[bufnum]), (
unsigned long long)size, newptr);
2886 const char* filename,
2908 const char* filename,
2929 const char* filename,
2935 assert( source != NULL );
2953 const char* filename,
2959 assert( source != NULL );
2976 const char* filename,
2982 assert( buffer != NULL );
2985 assert( ptr != NULL );
2986 assert( *ptr != NULL );
2993 while ( bufnum > 0 && buffer->
data[bufnum] != *ptr )
2996 #ifdef CHECKBUFFERORDER 2997 if ( bufnum < buffer->firstfree - 1 )
2999 warningMessage(
"[%s:%d]: freeing buffer in wrong order.\n", filename, line);
3004 if ( bufnum == 0 && buffer->
data[bufnum] != *ptr )
3007 printError(
"Tried to free unkown buffer pointer.\n");
3010 if ( ! buffer->
used[bufnum] )
3013 printError(
"Tried to free buffer pointer already freed.\n");
3022 char* tmpptr = (
char*)(buffer->
data[bufnum]);
3023 unsigned int inc = buffer->
size[bufnum] /
sizeof(*tmpptr);
3026 while( --tmpptr >= (
char*)(buffer->
data[bufnum]) )
3027 assert(*tmpptr ==
'\0');
3031 assert( buffer->
data[bufnum] == *ptr );
3037 debugMessage(
"Freed buffer %llu/%llu at %p of size %llu for pointer %p, first free is %llu.\n",
3038 (
unsigned long long)bufnum, (
unsigned long long)(buffer->
ndata), buffer->
data[bufnum],
3039 (
unsigned long long)(buffer->
size[bufnum]), *ptr, (
unsigned long long)(buffer->
firstfree));
3048 const char* filename,
3052 assert( ptr != NULL );
3054 #ifndef SCIP_NOBUFFERMEM 3060 printError(
"Tried to free null buffer pointer.\n");
3071 const char* filename,
3075 assert( ptr != NULL );
3079 #ifndef SCIP_NOBUFFERMEM 3092 assert( buffer != NULL );
3103 size_t totalmem = 0UL;
3106 assert( buffer != NULL );
3107 for (i = 0; i < buffer->
ndata; ++i)
3108 totalmem += buffer->
size[i];
3109 assert( totalmem == buffer->
totalmem );
3112 return (
long long) buffer->
totalmem;
3123 assert( buffer != NULL );
3126 for (i = 0; i < buffer->
ndata; ++i)
3128 printf(
"[%c] %8llu bytes at %p\n", buffer->
used[i] ?
'*' :
' ', (
unsigned long long)(buffer->
size[i]), buffer->
data[i]);
3129 totalmem += buffer->
size[i];
3131 printf(
" %8llu bytes total in %llu buffers\n", (
unsigned long long)totalmem, (
unsigned long long)(buffer->
ndata));
void BMSdestroyBlockMemory_call(BMS_BLKMEM **blkmem, const char *filename, int line)
long long BMSgetMemoryUsed_call(void)
void * BMSallocChunkMemory_call(BMS_CHKMEM *chkmem, size_t size, const char *filename, int line)
#define BMScopyMemorySize(ptr, source, size)
struct BMS_ChkMem BMS_CHKMEM
int BMSisAligned(size_t size)
static INLINE void BMSfreeBlockMemory_work(BMS_BLKMEM *blkmem, void **ptr, size_t size, const char *filename, int line)
#define BMSfreeMemoryArrayNull(ptr)
#define SCIP_RBTREE_HOOKS
void * BMSduplicateMemoryArray_call(const void *source, size_t num, size_t typesize, const char *filename, int line)
void BMSdisplayBlockMemory_call(const BMS_BLKMEM *blkmem)
void * BMSallocBlockMemoryArray_call(BMS_BLKMEM *blkmem, size_t num, size_t typesize, const char *filename, int line)
#define checkChunk(chunk)
static void freeChkmemElement(BMS_CHKMEM *chkmem, void *ptr, long long *memsize, const char *filename, int line)
void BMSfreeBufferMemoryNull_call(BMS_BUFMEM *buffer, void **ptr, const char *filename, int line)
void * BMSduplicateBufferMemoryArray_call(BMS_BUFMEM *buffer, const void *source, size_t num, size_t typesize, const char *filename, int line)
#define checkBlkmem(blkmem)
void * BMSallocBufferMemoryArray_call(BMS_BUFMEM *buffer, size_t num, size_t typesize, const char *filename, int line)
void * BMSduplicateChunkMemory_call(BMS_CHKMEM *chkmem, const void *source, size_t size, const char *filename, int line)
void * BMSallocClearBlockMemoryArray_call(BMS_BLKMEM *blkmem, size_t num, size_t typesize, const char *filename, int line)
void BMSdestroyChunkMemory_call(BMS_CHKMEM **chkmem, const char *filename, int line)
void * BMSallocBlockMemory_call(BMS_BLKMEM *blkmem, size_t size, const char *filename, int line)
size_t BMSgetBlockPointerSize_call(const BMS_BLKMEM *blkmem, const void *ptr)
long long BMScheckEmptyBlockMemory_call(const BMS_BLKMEM *blkmem)
void BMSfreeChunkMemory_call(BMS_CHKMEM *chkmem, void **ptr, size_t size, const char *filename, int line)
static void * allocChunkElement(CHUNK *chunk)
static void * allocChkmemElement(BMS_CHKMEM *chkmem, long long *memsize)
static SCIP_DEF_RBTREE_FIND(rbTreeFindChunk, const void *, CHUNK, CHUNK_LT, CHUNK_GT)
#define SCIPrbtreeDelete(root, node)
static void unlinkEagerChunk(CHUNK *chunk)
void * BMSreallocBlockMemoryArray_call(BMS_BLKMEM *blkmem, void *ptr, size_t oldnum, size_t newnum, size_t typesize, const char *filename, int line)
#define FOR_EACH_NODE(type, n, r, body)
void * BMSreallocBlockMemory_call(BMS_BLKMEM *blkmem, void *ptr, size_t oldsize, size_t newsize, const char *filename, int line)
#define BMSfreeMemory(ptr)
static BMS_CHKMEM * findChkmem(const BMS_BLKMEM *blkmem, const void *ptr)
static int linkChunk(BMS_CHKMEM *chkmem, CHUNK *chunk)
void * BMSallocClearBufferMemoryArray_call(BMS_BUFMEM *buffer, size_t num, size_t typesize, const char *filename, int line)
long long BMSgetBufferMemoryUsed(const BMS_BUFMEM *buffer)
void BMSsetBufferMemoryArraygrowinit(BMS_BUFMEM *buffer, int arraygrowinit)
static void freeChunk(CHUNK *chunk, long long *memsize)
long long BMSgetBlockMemoryUsedMax_call(const BMS_BLKMEM *blkmem)
void * BMSreallocMemoryArray_call(void *ptr, size_t num, size_t typesize, const char *filename, int line)
static void clearChkmem(BMS_CHKMEM *chkmem, long long *memsize)
static INLINE void * BMSallocBufferMemory_work(BMS_BUFMEM *buffer, size_t size, const char *filename, int line)
static INLINE void BMSfreeBufferMemory_work(BMS_BUFMEM *buffer, void **ptr, const char *filename, int line)
long long BMSgetBlockMemoryAllocated_call(const BMS_BLKMEM *blkmem)
void * BMSallocBufferMemory_call(BMS_BUFMEM *buffer, size_t size, const char *filename, int line)
static void unlinkChunk(CHUNK *chunk)
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)
static int createChunk(BMS_CHKMEM *chkmem, long long *memsize)
void * BMSallocMemory_call(size_t size, const char *filename, int line)
#define SCIPrbtreeInsert(r, p, c, n)
void BMSfreeBlockMemoryNull_call(BMS_BLKMEM *blkmem, void **ptr, size_t size, const char *filename, int line)
#define BMSallocClearMemorySize(ptr, size)
#define BMSallocMemory(ptr)
#define BMSreallocMemoryArray(ptr, num)
static CHUNK * findChunk(const BMS_CHKMEM *chkmem, const void *ptr)
static INLINE void * BMSreallocBufferMemory_work(BMS_BUFMEM *buffer, void *ptr, size_t size, const char *filename, int line)
static void destroyChunk(CHUNK *chunk, long long *memsize)
intrusive red black tree datastructure
BMS_CHKMEM * BMScreateChunkMemory_call(size_t size, int initchunksize, int garbagefactor, const char *filename, int line)
void BMSfreeMemoryNull_call(void **ptr, const char *filename, int line)
long long BMSgetBlockMemoryUnusedMax_call(const BMS_BLKMEM *blkmem)
static BMS_CHKMEM * createChkmem(int size, int initchunksize, int garbagefactor, long long *memsize)
void BMSfreeChunkMemoryNull_call(BMS_CHKMEM *chkmem, void **ptr, size_t size, const char *filename, int line)
static size_t calcMemoryGrowSize(size_t initsize, SCIP_Real growfac, size_t num)
common defines and data types used in all packages of SCIP
#define CHUNK_GT(ptr, chunk)
struct BMS_BlkMem BMS_BLKMEM
void * BMSreallocBufferMemory_call(BMS_BUFMEM *buffer, void *ptr, size_t size, const char *filename, int line)
void BMSclearBlockMemory_call(BMS_BLKMEM *blkmem, const char *filename, int line)
void BMSalignMemsize(size_t *size)
memory allocation routines