27 #define __STDC_LIMIT_MACROS 38 #ifndef NO_CONFIG_HEADER 39 #include "scip/config.h" 63 #ifdef SCIPdebugMessage 64 #define debugMessage SCIPdebugMessage 65 #define errorMessage SCIPerrorMessage 67 #define debugMessage while( FALSE ) printf 68 #define errorMessage printf 69 #define printErrorHeader(f,l) printf("[%s:%d] ERROR: ", f, l) 70 #define printError printf 73 #define warningMessage printf 74 #define printInfo printf 82 #define MAX(x,y) ((x) >= (y) ? (x) : (y)) 83 #define MIN(x,y) ((x) <= (y) ? (x) : (y)) 86 #ifndef SCIP_LONGINT_FORMAT 87 #if defined(_WIN32) || defined(_WIN64) 88 #define LONGINT_FORMAT "I64d" 90 #define LONGINT_FORMAT "lld" 93 #define LONGINT_FORMAT SCIP_LONGINT_FORMAT 96 #ifndef SCIP_MAXMEMSIZE 98 #define MAXMEMSIZE SIZE_MAX / 2 100 #define MAXMEMSIZE SCIP_MAXMEMSIZE 105 #if defined(_WIN32) || defined(_WIN64) || defined(__STDC__) 106 #define INLINE __inline 108 #define INLINE inline 119 #if !defined(NDEBUG) && defined(NPARASCIP) 121 typedef struct Memlist MEMLIST;
133 static MEMLIST* memlist =
NULL;
134 static size_t memused = 0;
143 MEMLIST* list = memlist;
146 while( list !=
NULL )
151 assert(used == memused);
154 #define checkMemlist() 159 void addMemlistEntry(
162 const char* filename,
168 assert(ptr !=
NULL && size > 0);
170 list = (MEMLIST*)malloc(
sizeof(MEMLIST));
171 assert(list !=
NULL);
175 list->filename = strdup(filename);
176 assert(list->filename !=
NULL);
178 list->next = memlist;
186 void removeMemlistEntry(
188 const char* filename,
199 while( list !=
NULL && ptr != list->ptr )
201 listptr = &(list->next);
206 assert(ptr == list->ptr);
208 *listptr = list->next;
209 assert( list->size <= memused );
210 memused -= list->size;
211 free(list->filename);
217 printError(
"Tried to free unknown pointer <%p>.\n", ptr);
230 while( list !=
NULL && ptr != list->ptr )
248 while( list !=
NULL )
250 printInfo(
"%12p %8llu %s:%d\n", list->ptr, (
unsigned long long) list->size, list->filename, list->line);
254 printInfo(
"Total: %8llu\n", (
unsigned long long) memused);
255 if( used != memused )
257 errorMessage(
"Used memory in list sums up to %llu instead of %llu\n", (
unsigned long long)used, (
unsigned long long)memused);
267 if( memlist !=
NULL || memused > 0 )
279 return (
long long) memused;
302 printInfo(
"Optimized version of memory shell linked - no memory diagnostics available.\n");
312 printInfo(
"Optimized version of memory shell linked - no memory leakage check available.\n");
330 const char* filename,
336 assert(typesize > 0);
338 debugMessage(
"calloc %llu elements of %llu bytes [%s:%d]\n", (
unsigned long long)num, (
unsigned long long)typesize,
351 typesize =
MAX(typesize, 1);
352 ptr = calloc(num, typesize);
357 printError(
"Insufficient memory for allocation of %llu bytes.\n", (
unsigned long long)(num) * (typesize));
359 #if !defined(NDEBUG) && defined(NPARASCIP) 361 addMemlistEntry(ptr, num*typesize, filename, line);
370 const char* filename,
376 debugMessage(
"malloc %llu bytes [%s:%d]\n", (
unsigned long long)size, filename, line);
393 printError(
"Insufficient memory for allocation of %llu bytes.\n", (
unsigned long long)size);
395 #if !defined(NDEBUG) && defined(NPARASCIP) 397 addMemlistEntry(ptr, size, filename, line);
407 const char* filename,
414 debugMessage(
"malloc %llu elements of %llu bytes [%s:%d]\n",
415 (
unsigned long long)num, (
unsigned long long)typesize, filename, line);
426 size = num * typesize;
433 printError(
"Insufficient memory for allocation of %llu bytes.\n", (
unsigned long long)size);
435 #if !defined(NDEBUG) && defined(NPARASCIP) 437 addMemlistEntry(ptr, size, filename, line);
447 const char* filename,
453 #if !defined(NDEBUG) && defined(NPARASCIP) 455 removeMemlistEntry(ptr, filename, line);
468 newptr = realloc(ptr, size);
473 printError(
"Insufficient memory for reallocation of %llu bytes.\n", (
unsigned long long)size);
475 #if !defined(NDEBUG) && defined(NPARASCIP) 477 addMemlistEntry(newptr, size, filename, line);
488 const char* filename,
495 #if !defined(NDEBUG) && defined(NPARASCIP) 497 removeMemlistEntry(ptr, filename, line);
509 size = num * typesize;
511 newptr = realloc(ptr, size);
516 printError(
"Insufficient memory for reallocation of %llu bytes.\n", (
unsigned long long)size);
518 #if !defined(NDEBUG) && defined(NPARASCIP) 520 addMemlistEntry(newptr, size, filename, line);
535 memset(ptr, 0, size);
549 assert(source !=
NULL);
550 memcpy(ptr, source, size);
566 assert(source !=
NULL);
567 memmove(ptr, source, size);
575 const char* filename,
581 assert(source !=
NULL || size == 0);
595 const char* filename,
601 assert(source !=
NULL || num == 0);
613 const char* filename,
617 assert( ptr !=
NULL );
620 #if !defined(NDEBUG) && defined(NPARASCIP) 621 removeMemlistEntry(*ptr, filename, line);
636 const char* filename,
640 assert( ptr !=
NULL );
643 #if !defined(NDEBUG) && defined(NPARASCIP) 644 removeMemlistEntry(*ptr, filename, line);
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 + 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)(
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 + i * chkmem->elemsize /
sizeof(
FREELIST*);
1085 freelist->next = (
FREELIST*) newchunk->store + (i + 1) * chkmem->elemsize /
sizeof(
FREELIST*);
1088 freelist = (
FREELIST*) newchunk->store + (newchunk->storesize - 1) * chkmem->elemsize /
sizeof(
FREELIST*);
1089 freelist->next = chkmem->lazyfree;
1090 chkmem->lazyfree = (
FREELIST*) (newchunk->store);
1091 chkmem->lazyfreesize += newchunk->storesize;
1108 assert(chunk !=
NULL);
1112 if( memsize !=
NULL )
1113 (*memsize) -= ((
long long)
sizeof(
CHUNK) + (
long long)chunk->storesize * chunk->elemsize);
1126 assert(chunk !=
NULL);
1127 assert(chunk->store !=
NULL);
1128 assert(chunk->eagerfree !=
NULL);
1129 assert(chunk->chkmem !=
NULL);
1130 assert(chunk->chkmem->rootchunk !=
NULL);
1131 assert(chunk->chkmem->firsteager !=
NULL);
1132 assert(chunk->eagerfreesize == chunk->storesize);
1134 debugMessage(
"freeing chunk %p of chunk block %p [elemsize: %d]\n", (
void*)chunk, (
void*)chunk->chkmem, chunk->chkmem->elemsize);
1137 chunk->chkmem->eagerfreesize -= chunk->eagerfreesize;
1138 assert(chunk->chkmem->eagerfreesize >= 0);
1158 assert(chunk !=
NULL);
1159 assert(chunk->eagerfree !=
NULL);
1160 assert(chunk->eagerfreesize > 0);
1161 assert(chunk->chkmem !=
NULL);
1163 debugMessage(
"allocating chunk element in chunk %p [elemsize: %d]\n", (
void*)chunk, chunk->chkmem->elemsize);
1166 ptr = chunk->eagerfree;
1167 chunk->eagerfree = ptr->next;
1168 chunk->eagerfreesize--;
1169 chunk->chkmem->eagerfreesize--;
1171 assert((chunk->eagerfreesize == 0 && chunk->eagerfree ==
NULL)
1172 || (chunk->eagerfreesize != 0 && chunk->eagerfree !=
NULL));
1173 assert(chunk->chkmem->eagerfreesize >= 0);
1176 if( chunk->eagerfree ==
NULL )
1178 assert(chunk->eagerfreesize == 0);
1194 assert(chunk !=
NULL);
1195 assert(chunk->chkmem !=
NULL);
1198 debugMessage(
"freeing chunk element %p of chunk %p [elemsize: %d]\n", (
void*)ptr, (
void*)chunk, chunk->chkmem->elemsize);
1201 if( chunk->eagerfree ==
NULL )
1203 assert(chunk->eagerfreesize == 0);
1208 ((
FREELIST*)ptr)->next = chunk->eagerfree;
1210 chunk->eagerfreesize++;
1211 chunk->chkmem->eagerfreesize++;
1232 if( chkmem ==
NULL )
1235 chkmem->lazyfree =
NULL;
1236 chkmem->rootchunk =
NULL;
1237 chkmem->firsteager =
NULL;
1238 chkmem->nextchkmem =
NULL;
1239 chkmem->elemsize = size;
1240 chkmem->nchunks = 0;
1241 chkmem->lastchunksize = 0;
1242 chkmem->storesize = 0;
1243 chkmem->lazyfreesize = 0;
1244 chkmem->eagerfreesize = 0;
1245 chkmem->initchunksize = initchunksize;
1246 chkmem->garbagefactor = garbagefactor;
1248 chkmem->filename =
NULL;
1250 chkmem->ngarbagecalls = 0;
1251 chkmem->ngarbagefrees = 0;
1254 if( memsize !=
NULL )
1267 assert(chkmem !=
NULL);
1272 SCIPrbtreeDelete(&chkmem->rootchunk, chunk);
1273 destroyChunk(chunk, memsize);
1276 chkmem->lazyfree =
NULL;
1277 chkmem->firsteager =
NULL;
1278 chkmem->nchunks = 0;
1279 chkmem->lastchunksize = 0;
1280 chkmem->storesize = 0;
1281 chkmem->lazyfreesize = 0;
1282 chkmem->eagerfreesize = 0;
1292 assert(chkmem !=
NULL);
1293 assert(*chkmem !=
NULL);
1301 if( memsize !=
NULL )
1302 (*memsize) -= (
long long)(
sizeof(
BMS_CHKMEM));
1316 assert(chkmem !=
NULL);
1319 if( chkmem->lazyfree ==
NULL )
1321 assert(chkmem->lazyfreesize == 0);
1324 if( chkmem->firsteager !=
NULL )
1333 assert(chkmem->lazyfree !=
NULL);
1334 assert(chkmem->lazyfreesize > 0);
1336 ptr = chkmem->lazyfree;
1337 chkmem->lazyfree = ptr->next;
1338 chkmem->lazyfreesize--;
1358 assert(chkmem !=
NULL);
1360 debugMessage(
"garbage collection for chunk block %p [elemsize: %d]\n", (
void*)chkmem, chkmem->elemsize);
1363 if( chkmem->lazyfreesize + chkmem->eagerfreesize == chkmem->storesize )
1370 chkmem->ngarbagecalls++;
1374 while( chkmem->lazyfree !=
NULL )
1377 lazyfree = chkmem->lazyfree;
1378 chkmem->lazyfree = chkmem->lazyfree->next;
1379 chkmem->lazyfreesize--;
1382 chunk =
findChunk(chkmem, (
void*)lazyfree);
1386 errorMessage(
"chunk for lazy free chunk %p not found in chunk block %p\n", (
void*)lazyfree, (
void*)chkmem);
1389 assert(chunk !=
NULL);
1393 assert(chunk->eagerfreesize > 0);
1395 assert(chkmem->lazyfreesize == 0);
1398 chunk = chkmem->firsteager;
1399 while( chunk !=
NULL && chkmem->nchunks > 1 )
1401 nexteager = chunk->nexteager;
1402 if( chunk->eagerfreesize == chunk->storesize )
1405 chkmem->ngarbagefrees++;
1421 const char* filename,
1425 assert(chkmem !=
NULL);
1426 assert(ptr !=
NULL);
1428 #if ( defined(CHECKMEM) || defined(CHECKCHKFREE) ) 1433 printError(
"Pointer %p does not belong to chunk block %p (size: %d).\n", ptr, chkmem, chkmem->elemsize);
1438 ((
FREELIST*)ptr)->next = chkmem->lazyfree;
1440 chkmem->lazyfreesize++;
1443 if( chkmem->garbagefactor >= 0 && chkmem->nchunks > 0 && chkmem->lazyfreesize >=
GARBAGE_SIZE 1444 && chkmem->lazyfreesize + chkmem->eagerfreesize
1445 > chkmem->garbagefactor * (
double)(chkmem->storesize) / (
double)(chkmem->nchunks) )
1459 const char* filename,
1467 if( chkmem ==
NULL )
1470 printError(
"Insufficient memory for chunk block.\n");
1472 debugMessage(
"created chunk memory %p [elemsize: %d]\n", (
void*)chkmem, (
int)size);
1480 const char* filename,
1484 debugMessage(
"clearing chunk memory %p [elemsize: %d]\n", (
void*)chkmem, chkmem->elemsize);
1486 if( chkmem !=
NULL )
1491 printError(
"Tried to clear null chunk block.\n");
1498 const char* filename,
1502 assert(chkmem !=
NULL);
1504 debugMessage(
"destroying chunk memory %p [elemsize: %d]\n", (
void*)*chkmem, (*chkmem)->elemsize);
1506 if( *chkmem !=
NULL )
1511 printError(
"Tried to destroy null chunk block.\n");
1519 const char* filename,
1525 assert(chkmem !=
NULL);
1526 assert((
int)size == chkmem->elemsize);
1533 printError(
"Insufficient memory for new chunk.\n");
1535 debugMessage(
"alloced %8llu bytes in %p [%s:%d]\n", (
unsigned long long)size, (
void*)ptr, filename, line);
1547 const char* filename,
1553 assert(chkmem !=
NULL);
1554 assert(source !=
NULL);
1555 assert((
int)size == chkmem->elemsize);
1569 const char* filename,
1573 assert(chkmem !=
NULL);
1574 assert((
int)size == chkmem->elemsize);
1575 assert( ptr !=
NULL );
1579 debugMessage(
"free %8d bytes in %p [%s:%d]\n", chkmem->elemsize, *ptr, filename, line);
1589 printError(
"Tried to free null chunk pointer.\n");
1598 const char* filename,
1602 assert(chkmem !=
NULL);
1603 assert((
int)size == chkmem->elemsize);
1604 assert( ptr !=
NULL );
1608 debugMessage(
"free %8d bytes in %p [%s:%d]\n", chkmem->elemsize, *ptr, filename, line);
1622 debugMessage(
"garbage collection on chunk memory %p [elemsize: %d]\n", (
void*)chkmem, chkmem->elemsize);
1632 assert(chkmem !=
NULL);
1634 return ((
long long)(chkmem->elemsize) * (
long long)(chkmem->storesize));
1660 long long tmpmemalloc = 0LL;
1661 long long tmpmemused = 0LL;
1664 assert(blkmem !=
NULL);
1665 assert(blkmem->chkmemhash !=
NULL);
1669 chkmem = blkmem->chkmemhash[i];
1670 while( chkmem !=
NULL )
1673 tmpmemalloc += ((chkmem->elemsize * chkmem->storesize) + chkmem->nchunks *
sizeof(
CHUNK) +
sizeof(
BMS_CHKMEM));
1674 tmpmemused += (chkmem->elemsize * (chkmem->storesize - chkmem->eagerfreesize - chkmem->lazyfreesize));
1675 chkmem = chkmem->nextchkmem;
1678 assert(tmpmemalloc == blkmem->memallocated);
1679 assert(tmpmemused == blkmem->memused);
1682 #define checkBlkmem(blkmem) 1700 assert(blkmem !=
NULL);
1705 chkmem = blkmem->chkmemhash[i];
1707 chkmem = chkmem->nextchkmem;
1722 return (
int) (((uint32_t)size * UINT32_C(0x9e3779b9))>>(32-
CHKHASH_POWER));
1730 const char* filename,
1738 if( blkmem !=
NULL )
1741 blkmem->chkmemhash[i] =
NULL;
1742 blkmem->initchunksize = initchunksize;
1743 blkmem->garbagefactor = garbagefactor;
1744 blkmem->memused = 0;
1745 blkmem->memallocated = 0;
1746 blkmem->maxmemused = 0;
1747 blkmem->maxmemunused = 0;
1748 blkmem->maxmemallocated = 0;
1753 printError(
"Insufficient memory for block memory header.\n");
1762 const char* filename,
1770 if( blkmem !=
NULL )
1774 chkmem = blkmem->chkmemhash[i];
1775 while( chkmem !=
NULL )
1777 nextchkmem = chkmem->nextchkmem;
1779 chkmem = nextchkmem;
1781 blkmem->chkmemhash[i] =
NULL;
1783 blkmem->memused = 0;
1784 assert(blkmem->memallocated == 0);
1789 printError(
"Tried to clear null block memory.\n");
1796 const char* filename,
1800 assert(blkmem !=
NULL);
1802 if( *blkmem !=
NULL )
1806 assert(*blkmem ==
NULL);
1811 printError(
"Tried to destroy null block memory.\n");
1820 const char* filename,
1828 assert( blkmem !=
NULL );
1835 chkmemptr = &(blkmem->chkmemhash[hashnumber]);
1836 while( *chkmemptr !=
NULL && (*chkmemptr)->elemsize != (
int)size )
1837 chkmemptr = &((*chkmemptr)->nextchkmem);
1840 if( *chkmemptr ==
NULL )
1842 *chkmemptr =
createChkmem((
int)size, blkmem->initchunksize, blkmem->garbagefactor, &blkmem->memallocated);
1843 if( *chkmemptr ==
NULL )
1846 printError(
"Insufficient memory for chunk block.\n");
1851 (*chkmemptr)->line = line;
1861 printError(
"Insufficient memory for new chunk.\n");
1863 debugMessage(
"alloced %8llu bytes in %p [%s:%d]\n", (
unsigned long long)size, ptr, filename, line);
1866 blkmem->memused += (
long long) size;
1867 blkmem->maxmemused =
MAX(blkmem->maxmemused, blkmem->memused);
1868 blkmem->maxmemunused =
MAX(blkmem->maxmemunused, blkmem->memallocated - blkmem->memused);
1869 blkmem->maxmemallocated =
MAX(blkmem->maxmemallocated, blkmem->memallocated);
1871 assert(blkmem->memused >= 0);
1872 assert(blkmem->memallocated >= 0);
1883 const char* filename,
1904 const char* filename,
1925 const char* filename,
1944 const char* filename,
1952 assert(oldsize == 0);
1965 alignSize(&oldsize);
1966 alignSize(&newsize);
1967 if( oldsize == newsize )
1971 if( newptr !=
NULL )
1985 const char* filename,
1993 assert(oldnum == 0);
2006 if ( oldnum == newnum )
2010 if ( newptr !=
NULL )
2022 const char* filename,
2028 assert(source !=
NULL);
2043 const char* filename,
2049 assert(source !=
NULL);
2064 const char* filename,
2071 assert(ptr !=
NULL);
2072 assert(*ptr !=
NULL);
2078 debugMessage(
"free %8llu bytes in %p [%s:%d]\n", (
unsigned long long)size, *ptr, filename, line);
2081 assert( blkmem->chkmemhash !=
NULL );
2082 chkmem = blkmem->chkmemhash[hashnumber];
2083 while( chkmem !=
NULL && chkmem->elemsize != (
int)size )
2084 chkmem = chkmem->nextchkmem;
2085 if( chkmem ==
NULL )
2088 printError(
"Tried to free pointer <%p> in block memory <%p> of unknown size %llu.\n", *ptr, (
void*)blkmem, (
unsigned long long)size);
2091 assert(chkmem->elemsize == (
int)size);
2095 blkmem->memused -= (
long long) size;
2097 blkmem->maxmemunused =
MAX(blkmem->maxmemunused, blkmem->memallocated - blkmem->memused);
2099 assert(blkmem->memused >= 0);
2100 assert(blkmem->memallocated >= 0);
2112 const char* filename,
2116 assert( blkmem !=
NULL );
2117 assert( ptr !=
NULL );
2121 else if( size != 0 )
2124 printError(
"Tried to free null block pointer.\n");
2134 const char* filename,
2138 assert( blkmem !=
NULL );
2139 assert( ptr !=
NULL );
2157 assert(blkmem !=
NULL);
2163 chkmemptr = &blkmem->chkmemhash[i];
2164 while( *chkmemptr !=
NULL )
2168 if( (*chkmemptr)->nchunks == 0 )
2172 assert((*chkmemptr)->lazyfreesize == 0);
2173 nextchkmem = (*chkmemptr)->nextchkmem;
2175 *chkmemptr = nextchkmem;
2179 chkmemptr = &(*chkmemptr)->nextchkmem;
2189 assert( blkmem !=
NULL );
2191 return blkmem->memallocated;
2199 assert( blkmem !=
NULL );
2201 return blkmem->memused;
2209 assert( blkmem !=
NULL );
2211 return blkmem->memallocated - blkmem->memused;
2219 assert( blkmem !=
NULL );
2221 return blkmem->maxmemused;
2229 assert( blkmem !=
NULL );
2231 return blkmem->maxmemunused;
2239 assert( blkmem !=
NULL );
2241 return blkmem->maxmemallocated;
2252 assert(blkmem !=
NULL);
2258 if( chkmem ==
NULL )
2261 return (
size_t)(chkmem->elemsize);
2271 int nunusedblocks = 0;
2272 int totalnchunks = 0;
2273 int totalneagerchunks = 0;
2274 int totalnelems = 0;
2275 int totalneagerelems = 0;
2276 int totalnlazyelems = 0;
2278 int totalngarbagecalls = 0;
2279 int totalngarbagefrees = 0;
2281 long long allocedmem = 0;
2282 long long freemem = 0;
2286 printInfo(
" ElSize #Chunk #Eag #Elems #EagFr #LazFr #GCl #GFr Free MBytes First Allocator\n");
2288 printInfo(
" ElSize #Chunk #Eag #Elems #EagFr #LazFr Free MBytes\n");
2291 assert(blkmem !=
NULL);
2295 chkmem = blkmem->chkmemhash[i];
2296 while( chkmem !=
NULL )
2300 int neagerchunks = 0;
2301 int neagerelems = 0;
2305 assert(chunk != NULL);
2306 assert(chunk->elemsize == chkmem->elemsize);
2307 assert(chunk->chkmem == chkmem);
2309 nelems += chunk->storesize;
2310 if( chunk->eagerfree != NULL )
2313 neagerelems += chunk->eagerfreesize;
2317 assert(nchunks == chkmem->nchunks);
2318 assert(nelems == chkmem->storesize);
2319 assert(neagerelems == chkmem->eagerfreesize);
2324 allocedmem += (
long long)chkmem->elemsize * (
long long)nelems;
2325 freemem += (
long long)chkmem->elemsize * ((
long long)neagerelems + (
long long)chkmem->lazyfreesize);
2328 printInfo(
"%7d %6d %4d %7d %7d %7d %5d %4d %5.1f%% %6.1f %s:%d\n",
2329 chkmem->elemsize, nchunks, neagerchunks, nelems,
2330 neagerelems, chkmem->lazyfreesize, chkmem->ngarbagecalls, chkmem->ngarbagefrees,
2331 100.0 * (
double) (neagerelems + chkmem->lazyfreesize) / (
double) (nelems),
2332 (
double)chkmem->elemsize * nelems / (1024.0*1024.0),
2333 chkmem->filename, chkmem->line);
2335 printInfo(
"%7d %6d %4d %7d %7d %7d %5.1f%% %6.1f\n",
2336 chkmem->elemsize, nchunks, neagerchunks, nelems,
2337 neagerelems, chkmem->lazyfreesize,
2338 100.0 * (
double) (neagerelems + chkmem->lazyfreesize) / (
double) (nelems),
2339 (
double)chkmem->elemsize * nelems / (1024.0*1024.0));
2345 printInfo(
"%7d <unused> %5d %4d %s:%d\n",
2346 chkmem->elemsize, chkmem->ngarbagecalls, chkmem->ngarbagefrees,
2347 chkmem->filename, chkmem->line);
2349 printInfo(
"%7d <unused>\n", chkmem->elemsize);
2353 totalnchunks += nchunks;
2354 totalneagerchunks += neagerchunks;
2355 totalnelems += nelems;
2356 totalneagerelems += neagerelems;
2357 totalnlazyelems += chkmem->lazyfreesize;
2359 totalngarbagecalls += chkmem->ngarbagecalls;
2360 totalngarbagefrees += chkmem->ngarbagefrees;
2362 chkmem = chkmem->nextchkmem;
2366 printInfo(
" Total %6d %4d %7d %7d %7d %5d %4d %5.1f%% %6.1f\n",
2367 totalnchunks, totalneagerchunks, totalnelems, totalneagerelems, totalnlazyelems,
2368 totalngarbagecalls, totalngarbagefrees,
2369 totalnelems > 0 ? 100.0 * (
double) (totalneagerelems + totalnlazyelems) / (
double) (totalnelems) : 0.0,
2370 (
double)allocedmem/(1024.0*1024.0));
2372 printInfo(
" Total %6d %4d %7d %7d %7d %5.1f%% %6.1f\n",
2373 totalnchunks, totalneagerchunks, totalnelems, totalneagerelems, totalnlazyelems,
2374 totalnelems > 0 ? 100.0 * (
double) (totalneagerelems + totalnlazyelems) / (
double) (totalnelems) : 0.0,
2375 (
double)allocedmem/(1024.0*1024.0));
2378 nblocks + nunusedblocks, nunusedblocks, allocedmem, freemem);
2379 if( allocedmem > 0 )
2380 printInfo(
" (%.1f%%)", 100.0 * (
double) freemem / (
double) allocedmem);
2383 printInfo(
"Memory Peaks: Used Lazy Total\n");
2384 printInfo(
" %6.1f %6.1f %6.1f MBytes\n", (
double)blkmem->maxmemused / (1024.0 * 1024.0),
2385 (
double)blkmem->maxmemunused / (1024.0 * 1024.0), (
double)blkmem->maxmemallocated / (1024.0 * 1024.0));
2394 long long allocedmem = 0;
2395 long long freemem = 0;
2398 assert(blkmem !=
NULL);
2402 chkmem = blkmem->chkmemhash[i];
2403 while( chkmem !=
NULL )
2407 int neagerelems = 0;
2411 assert(chunk != NULL);
2412 assert(chunk->elemsize == chkmem->elemsize);
2413 assert(chunk->chkmem == chkmem);
2415 nelems += chunk->storesize;
2416 if( chunk->eagerfree != NULL )
2417 neagerelems += chunk->eagerfreesize;
2420 assert(nchunks == chkmem->nchunks);
2421 assert(nelems == chkmem->storesize);
2422 assert(neagerelems == chkmem->eagerfreesize);
2426 allocedmem += (
long long)chkmem->elemsize * (
long long)nelems;
2427 freemem += (
long long)chkmem->elemsize * ((
long long)neagerelems + (
long long)chkmem->lazyfreesize);
2429 if( nelems != neagerelems + chkmem->lazyfreesize )
2433 (((
long long)nelems - (
long long)neagerelems) - (
long long)chkmem->lazyfreesize)
2434 * (
long long)(chkmem->elemsize),
2435 (nelems - neagerelems) - chkmem->lazyfreesize, (
long long)(chkmem->elemsize),
2436 chkmem->filename, chkmem->line);
2438 errorMessage(
"%" LONGINT_FORMAT
" bytes (%d elements of size %" LONGINT_FORMAT
") not freed.\n",
2439 ((nelems - neagerelems) - chkmem->lazyfreesize) * (
long long)(chkmem->elemsize),
2440 (nelems - neagerelems) - chkmem->lazyfreesize, (
long long)(chkmem->elemsize));
2444 chkmem = chkmem->nextchkmem;
2448 if( allocedmem != freemem )
2453 return allocedmem - freemem;
2484 double arraygrowfac,
2487 const char* filename,
2493 assert( arraygrowinit > 0 );
2494 assert( arraygrowfac > 0.0 );
2497 if ( buffer !=
NULL )
2503 buffer->
clean = clean;
2512 printError(
"Insufficient memory for buffer memory header.\n");
2521 const char* filename,
2527 if ( *buffer !=
NULL )
2529 i = (*buffer)->ndata;
2533 assert( ! (*buffer)->used[i] );
2547 printError(
"Tried to free null buffer memory.\n");
2557 assert( buffer !=
NULL );
2558 assert( arraygrowfac > 0.0 );
2569 assert( buffer !=
NULL );
2570 assert( arraygrowinit > 0 );
2575 #ifndef SCIP_NOBUFFERMEM 2589 assert( growfac >= 1.0 );
2591 if ( growfac == 1.0 )
2592 size =
MAX(initsize, num);
2598 initsize =
MAX(initsize, 4);
2603 while ( size < num && size > oldsize )
2606 size = (size_t)(growfac * size + initsize);
2610 if ( size <= oldsize )
2614 assert( size >= initsize );
2615 assert( size >= num );
2626 const char* filename,
2632 #ifndef SCIP_NOBUFFERMEM 2636 #ifndef SCIP_NOBUFFERMEM 2637 assert( buffer !=
NULL );
2656 printError(
"Insufficient memory for reallocating buffer data storage.\n");
2663 printError(
"Insufficient memory for reallocating buffer size storage.\n");
2670 printError(
"Insufficient memory for reallocating buffer used storage.\n");
2675 for (i = buffer->
ndata; i < newsize; ++i)
2678 buffer->
size[i] = 0;
2681 buffer->
ndata = newsize;
2687 assert( ! buffer->
used[bufnum] );
2688 if ( buffer->
size[bufnum] < size )
2699 char* tmpptr = (
char*)(buffer->
data[bufnum]);
2700 size_t inc = buffer->
size[bufnum] /
sizeof(*tmpptr);
2705 assert( newsize > buffer->
size[bufnum] );
2707 buffer->
size[bufnum] = newsize;
2709 if ( buffer->
data[bufnum] ==
NULL )
2712 printError(
"Insufficient memory for reallocating buffer storage.\n");
2716 assert( buffer->
size[bufnum] >= size );
2722 char* tmpptr = (
char*)(buffer->
data[bufnum]);
2723 unsigned int inc = buffer->
size[bufnum] /
sizeof(*tmpptr);
2726 while( --tmpptr >= (
char*)(buffer->
data[bufnum]) )
2727 assert(*tmpptr ==
'\0');
2731 ptr = buffer->
data[bufnum];
2735 debugMessage(
"Allocated buffer %llu/%llu at %p of size %llu (required size: %llu) for pointer %p.\n",
2736 (
unsigned long long)bufnum, (
unsigned long long)(buffer->
ndata), buffer->
data[bufnum],
2737 (
unsigned long long)(buffer->
size[bufnum]), (
unsigned long long)size, ptr);
2760 const char* filename,
2781 const char* filename,
2802 const char* filename,
2821 const char* filename,
2826 #ifndef SCIP_NOBUFFERMEM 2830 #ifndef SCIP_NOBUFFERMEM 2831 assert( buffer !=
NULL );
2833 assert(!buffer->
clean);
2846 while ( bufnum > 0 && buffer->
data[bufnum] != ptr )
2850 assert( buffer->
data[bufnum] == newptr );
2851 assert( buffer->
used[bufnum] );
2852 assert( buffer->
size[bufnum] >= 1 );
2855 if ( size > buffer->
size[bufnum] )
2862 assert( newsize > buffer->
size[bufnum] );
2864 buffer->
size[bufnum] = newsize;
2865 if ( buffer->
data[bufnum] ==
NULL )
2868 printError(
"Insufficient memory for reallocating buffer storage.\n");
2871 newptr = buffer->
data[bufnum];
2873 assert( buffer->
size[bufnum] >= size );
2874 assert( newptr == buffer->
data[bufnum] );
2876 debugMessage(
"Reallocated buffer %llu/%llu at %p to size %llu (required size: %llu) for pointer %p.\n",
2877 (
unsigned long long)bufnum, (
unsigned long long)(buffer->
ndata), buffer->
data[bufnum],
2878 (
unsigned long long)(buffer->
size[bufnum]), (
unsigned long long)size, newptr);
2893 const char* filename,
2915 const char* filename,
2936 const char* filename,
2942 assert( source !=
NULL );
2960 const char* filename,
2966 assert( source !=
NULL );
2983 const char* filename,
2989 assert( buffer !=
NULL );
2992 assert( ptr !=
NULL );
2993 assert( *ptr !=
NULL );
3000 while ( bufnum > 0 && buffer->
data[bufnum] != *ptr )
3003 #ifdef CHECKBUFFERORDER 3004 if ( bufnum < buffer->firstfree - 1 )
3006 warningMessage(
"[%s:%d]: freeing buffer in wrong order.\n", filename, line);
3011 if ( bufnum == 0 && buffer->
data[bufnum] != *ptr )
3014 printError(
"Tried to free unkown buffer pointer.\n");
3017 if ( ! buffer->
used[bufnum] )
3020 printError(
"Tried to free buffer pointer already freed.\n");
3030 uint8_t* tmpptr = (uint8_t*)(buffer->
data[bufnum]);
3032 for( i = 0; i < buffer->
size[bufnum]; ++i )
3033 assert(tmpptr[i] == 0);
3037 assert( buffer->
data[bufnum] == *ptr );
3043 debugMessage(
"Freed buffer %llu/%llu at %p of size %llu for pointer %p, first free is %llu.\n",
3044 (
unsigned long long)bufnum, (
unsigned long long)(buffer->
ndata), buffer->
data[bufnum],
3045 (
unsigned long long)(buffer->
size[bufnum]), *ptr, (
unsigned long long)(buffer->
firstfree));
3054 const char* filename,
3058 assert( ptr !=
NULL );
3060 #ifndef SCIP_NOBUFFERMEM 3066 printError(
"Tried to free null buffer pointer.\n");
3077 const char* filename,
3081 assert( ptr !=
NULL );
3085 #ifndef SCIP_NOBUFFERMEM 3098 assert( buffer !=
NULL );
3109 size_t totalmem = 0UL;
3112 assert( buffer !=
NULL );
3113 for (i = 0; i < buffer->
ndata; ++i)
3114 totalmem += buffer->
size[i];
3115 assert( totalmem == buffer->
totalmem );
3118 return (
long long) buffer->
totalmem;
3129 assert( buffer !=
NULL );
3132 for (i = 0; i < buffer->
ndata; ++i)
3134 printf(
"[%c] %8llu bytes at %p\n", buffer->
used[i] ?
'*' :
' ', (
unsigned long long)(buffer->
size[i]), buffer->
data[i]);
3135 totalmem += buffer->
size[i];
3137 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 printErrorHeader(f, l)
#define BMSfreeMemory(ptr)
static BMS_CHKMEM * findChkmem(const BMS_BLKMEM *blkmem, const void *ptr)
static int linkChunk(BMS_CHKMEM *chkmem, CHUNK *chunk)
void * BMSallocClearBufferMemoryArray_call(BMS_BUFMEM *buffer, size_t num, size_t typesize, const char *filename, int line)
long long BMSgetBufferMemoryUsed(const BMS_BUFMEM *buffer)
void BMSsetBufferMemoryArraygrowinit(BMS_BUFMEM *buffer, int arraygrowinit)
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