27 #define __STDC_LIMIT_MACROS 55 #ifdef SCIPdebugMessage 56 #define debugMessage SCIPdebugMessage 57 #define errorMessage SCIPerrorMessage 59 #define debugMessage while( FALSE ) printf 60 #define errorMessage printf 61 #define printErrorHeader(f,l) printf("[%s:%d] ERROR: ", f, l) 62 #define printError printf 65 #define warningMessage printf 66 #define printInfo printf 74 #define MAX(x,y) ((x) >= (y) ? (x) : (y)) 75 #define MIN(x,y) ((x) <= (y) ? (x) : (y)) 78 #ifndef SCIP_LONGINT_FORMAT 79 #if defined(_WIN32) || defined(_WIN64) 80 #define LONGINT_FORMAT "I64d" 82 #define LONGINT_FORMAT "lld" 85 #define LONGINT_FORMAT SCIP_LONGINT_FORMAT 88 #ifndef SCIP_MAXMEMSIZE 90 #define MAXMEMSIZE SIZE_MAX / 2 92 #define MAXMEMSIZE SCIP_MAXMEMSIZE 97 #if defined(_WIN32) || defined(_WIN64) || defined(__STDC__) 98 #define INLINE __inline 100 #define INLINE inline 111 #if !defined(NDEBUG) && defined(NPARASCIP) 113 typedef struct Memlist MEMLIST;
125 static MEMLIST* memlist =
NULL;
126 static size_t memused = 0;
135 MEMLIST* list = memlist;
138 while( list !=
NULL )
143 assert(used == memused);
146 #define checkMemlist() 151 void addMemlistEntry(
154 const char* filename,
160 assert(ptr !=
NULL && size > 0);
162 list = (MEMLIST*)malloc(
sizeof(MEMLIST));
163 assert(list !=
NULL);
167 list->filename = strdup(filename);
168 assert(list->filename !=
NULL);
170 list->next = memlist;
178 void removeMemlistEntry(
180 const char* filename,
191 while( list !=
NULL && ptr != list->ptr )
193 listptr = &(list->next);
198 assert(ptr == list->ptr);
200 *listptr = list->next;
201 assert( list->size <= memused );
202 memused -= list->size;
203 free(list->filename);
209 printError(
"Tried to free unknown pointer <%p>.\n", ptr);
222 while( list !=
NULL && ptr != list->ptr )
240 while( list !=
NULL )
242 printInfo(
"%12p %8llu %s:%d\n", list->ptr, (
unsigned long long) list->size, list->filename, list->line);
246 printInfo(
"Total: %8llu\n", (
unsigned long long) memused);
247 if( used != memused )
249 errorMessage(
"Used memory in list sums up to %llu instead of %llu\n", (
unsigned long long)used, (
unsigned long long)memused);
259 if( memlist !=
NULL || memused > 0 )
271 return (
long long) memused;
294 printInfo(
"Optimized version of memory shell linked - no memory diagnostics available.\n");
304 printInfo(
"Optimized version of memory shell linked - no memory leakage check available.\n");
322 const char* filename,
328 debugMessage(
"calloc %llu elements of %llu bytes [%s:%d]\n", (
unsigned long long)num, (
unsigned long long)typesize,
341 typesize =
MAX(typesize, 1);
342 ptr = calloc(num, typesize);
347 printError(
"Insufficient memory for allocation of %llu bytes.\n", (
unsigned long long)(num * typesize));
349 #if !defined(NDEBUG) && defined(NPARASCIP) 351 addMemlistEntry(ptr, num*typesize, filename, line);
360 const char* filename,
366 debugMessage(
"malloc %llu bytes [%s:%d]\n", (
unsigned long long)size, filename, line);
383 printError(
"Insufficient memory for allocation of %llu bytes.\n", (
unsigned long long)size);
385 #if !defined(NDEBUG) && defined(NPARASCIP) 387 addMemlistEntry(ptr, size, filename, line);
397 const char* filename,
404 debugMessage(
"malloc %llu elements of %llu bytes [%s:%d]\n",
405 (
unsigned long long)num, (
unsigned long long)typesize, filename, line);
416 size = num * typesize;
423 printError(
"Insufficient memory for allocation of %llu bytes.\n", (
unsigned long long)size);
425 #if !defined(NDEBUG) && defined(NPARASCIP) 427 addMemlistEntry(ptr, size, filename, line);
437 const char* filename,
443 #if !defined(NDEBUG) && defined(NPARASCIP) 445 removeMemlistEntry(ptr, filename, line);
458 newptr = realloc(ptr, size);
463 printError(
"Insufficient memory for reallocation of %llu bytes.\n", (
unsigned long long)size);
465 #if !defined(NDEBUG) && defined(NPARASCIP) 467 addMemlistEntry(newptr, size, filename, line);
478 const char* filename,
485 #if !defined(NDEBUG) && defined(NPARASCIP) 487 removeMemlistEntry(ptr, filename, line);
499 size = num * typesize;
501 newptr = realloc(ptr, size);
506 printError(
"Insufficient memory for reallocation of %llu bytes.\n", (
unsigned long long)size);
508 #if !defined(NDEBUG) && defined(NPARASCIP) 510 addMemlistEntry(newptr, size, filename, line);
525 memset(ptr, 0, size);
539 assert(source !=
NULL);
540 memcpy(ptr, source, size);
556 assert(source !=
NULL);
557 memmove(ptr, source, size);
565 const char* filename,
571 assert(source !=
NULL || size == 0);
585 const char* filename,
591 assert(source !=
NULL || num == 0);
603 const char* filename,
607 assert( ptr !=
NULL );
610 #if !defined(NDEBUG) && defined(NPARASCIP) 611 removeMemlistEntry(*ptr, filename, line);
626 const char* filename,
630 assert( ptr !=
NULL );
633 #if !defined(NDEBUG) && defined(NPARASCIP) 634 removeMemlistEntry(*ptr, filename, line);
648 #define CHKHASH_POWER 10 649 #define CHKHASH_SIZE (1<<CHKHASH_POWER) 656 long long memallocated;
657 long long maxmemused;
658 long long maxmemunused;
659 long long maxmemallocated;
676 #define CHUNKLENGTH_MIN 1024 677 #define CHUNKLENGTH_MAX 1048576 678 #define STORESIZE_MAX 8192 679 #define GARBAGE_SIZE 256 680 #define ALIGNMENT (sizeof(FREELIST)) 770 assert(chunk !=
NULL);
771 assert(chunk->store <= chunk->storeend);
773 return (ptr >= (
void*)(chunk->store) && ptr < (
void*)(chunk->storeend));
792 assert(chkmem !=
NULL);
797 right = chkmem->nchunks-1;
798 while( left <= right )
800 middle = (left+right)/2;
801 assert(0 <= middle && middle < chkmem->nchunks);
802 chunk = chkmem->chunks[middle];
803 assert(chunk !=
NULL);
804 if( ptr < chunk->store )
806 else if( ptr >= chunk->storeend )
823 assert(chkmem !=
NULL);
844 assert(chunk !=
NULL);
845 assert(chunk->store !=
NULL);
846 assert(chunk->storeend == (
void*)((
char*)(chunk->store) + chunk->elemsize * chunk->storesize));
847 assert(chunk->chkmem !=
NULL);
848 assert(chunk->chkmem->elemsize == chunk->elemsize);
850 if( chunk->eagerfree ==
NULL )
851 assert(chunk->nexteager ==
NULL && chunk->preveager ==
NULL);
852 else if( chunk->preveager ==
NULL )
853 assert(chunk->chkmem->firsteager == chunk);
855 if( chunk->nexteager !=
NULL )
856 assert(chunk->nexteager->preveager == chunk);
857 if( chunk->preveager !=
NULL )
858 assert(chunk->preveager->nexteager == chunk);
861 eager = chunk->eagerfree;
862 while( eager !=
NULL )
868 assert(chunk->eagerfreesize == eagerfreesize);
885 assert(chkmem !=
NULL);
886 assert(chkmem->chunks !=
NULL || chkmem->chunkssize == 0);
887 assert(chkmem->nchunks <= chkmem->chunkssize);
894 for( i = 0; i < chkmem->nchunks; ++i )
896 chunk = chkmem->chunks[i];
897 assert(chunk !=
NULL);
901 storesize += chunk->storesize;
902 eagerfreesize += chunk->eagerfreesize;
904 assert(chkmem->nchunks == nchunks);
905 assert(chkmem->storesize == storesize);
906 assert(chkmem->eagerfreesize == eagerfreesize);
908 assert(((
unsigned int) (chkmem->eagerfreesize == 0)) ^ ( (
unsigned int) (chkmem->firsteager !=
NULL)));
910 if( chkmem->firsteager !=
NULL )
911 assert(chkmem->firsteager->preveager ==
NULL);
913 lazy = chkmem->lazyfree;
914 while( lazy !=
NULL )
917 assert(chunk !=
NULL);
918 assert(chunk->chkmem == chkmem);
922 assert(chkmem->lazyfreesize == lazyfreesize);
925 #define checkChunk(chunk) 926 #define checkChkmem(chkmem) 946 assert(chkmem !=
NULL);
947 assert(chkmem->nchunks <= chkmem->chunkssize);
948 assert(chunk !=
NULL);
949 assert(chunk->store !=
NULL);
951 debugMessage(
"linking chunk %p to chunk block %p [elemsize:%d, %d chunks]\n",
952 (
void*)chunk, (
void*)chkmem, chkmem->elemsize, chkmem->nchunks);
956 right = chkmem->nchunks;
957 while( left < right-1 )
959 middle = (left+right)/2;
960 assert(0 <= middle && middle < chkmem->nchunks);
961 assert(left < middle && middle < right);
962 curchunk = chkmem->chunks[middle];
963 assert(curchunk !=
NULL);
964 if( chunk->store < curchunk->store )
968 assert(chunk->store >= curchunk->storeend);
972 assert(-1 <= left && left < chkmem->nchunks);
973 assert(0 <= right && right <= chkmem->nchunks);
974 assert(left+1 == right);
975 assert(left == -1 || chkmem->chunks[left]->storeend <= chunk->store);
976 assert(right == chkmem->nchunks || chunk->storeend <= chkmem->chunks[right]->store);
979 if( chkmem->nchunks == chkmem->chunkssize )
981 chkmem->chunkssize = 2*(chkmem->nchunks+1);
983 if( chkmem->chunks ==
NULL )
986 if( memsize !=
NULL )
987 (*memsize) += (
long long)((chkmem->chunkssize - chkmem->nchunks) *
sizeof(
CHUNK*));
990 assert(chkmem->nchunks < chkmem->chunkssize);
991 assert(chkmem->chunks !=
NULL);
994 for( i = chkmem->nchunks; i > right; --i )
996 chkmem->chunks[i] = chkmem->chunks[i-1];
997 chkmem->chunks[i]->arraypos = i;
1001 chunk->arraypos = right;
1002 chkmem->chunks[right] = chunk;
1004 chkmem->storesize += chunk->storesize;
1018 assert(chunk !=
NULL);
1019 assert(chunk->eagerfree ==
NULL);
1020 assert(chunk->nexteager ==
NULL);
1021 assert(chunk->preveager ==
NULL);
1023 chkmem = chunk->chkmem;
1024 assert(chkmem !=
NULL);
1025 assert(chkmem->elemsize == chunk->elemsize);
1026 assert(0 <= chunk->arraypos && chunk->arraypos < chkmem->nchunks);
1027 assert(chkmem->chunks[chunk->arraypos] == chunk);
1029 debugMessage(
"unlinking chunk %p from chunk block %p [elemsize:%d, %d chunks]\n",
1030 (
void*)chunk, (
void*)chkmem, chkmem->elemsize, chkmem->nchunks);
1033 for( i = chunk->arraypos; i < chkmem->nchunks-1; ++i )
1035 chkmem->chunks[i] = chkmem->chunks[i+1];
1036 chkmem->chunks[i]->arraypos = i;
1039 chkmem->storesize -= chunk->storesize;
1049 assert(chunk->chkmem == chkmem);
1050 assert(chunk->nexteager ==
NULL);
1051 assert(chunk->preveager ==
NULL);
1053 chunk->nexteager = chkmem->firsteager;
1054 chunk->preveager =
NULL;
1055 if( chkmem->firsteager !=
NULL )
1057 assert(chkmem->firsteager->preveager ==
NULL);
1058 chkmem->firsteager->preveager = chunk;
1060 chkmem->firsteager = chunk;
1069 assert(chunk !=
NULL);
1070 assert(chunk->eagerfreesize == 0 || chunk->eagerfreesize == chunk->storesize);
1072 if( chunk->nexteager !=
NULL )
1073 chunk->nexteager->preveager = chunk->preveager;
1074 if( chunk->preveager !=
NULL )
1075 chunk->preveager->nexteager = chunk->nexteager;
1078 assert(chunk->chkmem->firsteager == chunk);
1079 chunk->chkmem->firsteager = chunk->nexteager;
1081 chunk->nexteager =
NULL;
1082 chunk->preveager =
NULL;
1083 chunk->eagerfree =
NULL;
1101 assert(chkmem !=
NULL);
1103 debugMessage(
"creating new chunk in chunk block %p [elemsize: %d]\n", (
void*)chkmem, chkmem->elemsize);
1106 if( chkmem->nchunks == 0 )
1107 storesize = chkmem->initchunksize;
1109 storesize = 2 * chkmem->lastchunksize;
1110 assert(storesize > 0);
1114 storesize =
MAX(storesize, 1);
1115 chkmem->lastchunksize = storesize;
1119 assert( chkmem->elemsize < INT_MAX / storesize );
1120 assert(
sizeof(
CHUNK) <
MAXMEMSIZE - (
size_t)(storesize * chkmem->elemsize) );
1122 if( newchunk ==
NULL )
1126 newchunk->store = (
void*) ((
char*) newchunk +
sizeof(
CHUNK));
1127 newchunk->storeend = (
void*) ((
char*) newchunk->store + storesize * chkmem->elemsize);
1128 newchunk->eagerfree =
NULL;
1129 newchunk->nexteager =
NULL;
1130 newchunk->preveager =
NULL;
1131 newchunk->chkmem = chkmem;
1132 newchunk->elemsize = chkmem->elemsize;
1133 newchunk->storesize = storesize;
1134 newchunk->eagerfreesize = 0;
1135 newchunk->arraypos = -1;
1137 if( memsize !=
NULL )
1138 (*memsize) += ((
long long)(
sizeof(
CHUNK) + (
long long)storesize * chkmem->elemsize));
1140 debugMessage(
"allocated new chunk %p: %d elements with size %d\n", (
void*)newchunk, newchunk->storesize, newchunk->elemsize);
1145 for( i = 0; i < newchunk->storesize - 1; ++i )
1147 freelist = (
FREELIST*) newchunk->store + i * chkmem->elemsize /
sizeof(
FREELIST*);
1148 freelist->next = (
FREELIST*) newchunk->store + (i + 1) * chkmem->elemsize /
sizeof(
FREELIST*);
1151 freelist = (
FREELIST*) newchunk->store + (newchunk->storesize - 1) * chkmem->elemsize /
sizeof(
FREELIST*);
1152 freelist->next = chkmem->lazyfree;
1153 chkmem->lazyfree = (
FREELIST*) (newchunk->store);
1154 chkmem->lazyfreesize += newchunk->storesize;
1157 retval =
linkChunk(chkmem, newchunk, memsize);
1171 assert(chunk !=
NULL);
1175 if( memsize !=
NULL )
1176 (*memsize) -= ((
long long)
sizeof(
CHUNK) + (
long long)chunk->storesize * chunk->elemsize);
1189 assert(chunk !=
NULL);
1190 assert(chunk->store !=
NULL);
1191 assert(chunk->eagerfree !=
NULL);
1192 assert(chunk->chkmem !=
NULL);
1193 assert(chunk->chkmem->chunks !=
NULL);
1194 assert(chunk->chkmem->firsteager !=
NULL);
1195 assert(chunk->eagerfreesize == chunk->storesize);
1197 debugMessage(
"freeing chunk %p of chunk block %p [elemsize: %d]\n", (
void*)chunk, (
void*)chunk->chkmem, chunk->chkmem->elemsize);
1200 chunk->chkmem->eagerfreesize -= chunk->eagerfreesize;
1201 assert(chunk->chkmem->eagerfreesize >= 0);
1221 assert(chunk !=
NULL);
1222 assert(chunk->eagerfree !=
NULL);
1223 assert(chunk->eagerfreesize > 0);
1224 assert(chunk->chkmem !=
NULL);
1226 debugMessage(
"allocating chunk element in chunk %p [elemsize: %d]\n", (
void*)chunk, chunk->chkmem->elemsize);
1229 ptr = chunk->eagerfree;
1230 chunk->eagerfree = ptr->next;
1231 chunk->eagerfreesize--;
1232 chunk->chkmem->eagerfreesize--;
1234 assert((chunk->eagerfreesize == 0 && chunk->eagerfree ==
NULL)
1235 || (chunk->eagerfreesize != 0 && chunk->eagerfree !=
NULL));
1236 assert(chunk->chkmem->eagerfreesize >= 0);
1239 if( chunk->eagerfree ==
NULL )
1241 assert(chunk->eagerfreesize == 0);
1257 assert(chunk !=
NULL);
1258 assert(chunk->chkmem !=
NULL);
1261 debugMessage(
"freeing chunk element %p of chunk %p [elemsize: %d]\n", (
void*)ptr, (
void*)chunk, chunk->chkmem->elemsize);
1264 if( chunk->eagerfree ==
NULL )
1266 assert(chunk->eagerfreesize == 0);
1271 ((
FREELIST*)ptr)->next = chunk->eagerfree;
1273 chunk->eagerfreesize++;
1274 chunk->chkmem->eagerfreesize++;
1295 if( chkmem ==
NULL )
1298 chkmem->lazyfree =
NULL;
1299 chkmem->chunks =
NULL;
1300 chkmem->firsteager =
NULL;
1301 chkmem->nextchkmem =
NULL;
1302 chkmem->elemsize = size;
1303 chkmem->chunkssize = 0;
1304 chkmem->nchunks = 0;
1305 chkmem->lastchunksize = 0;
1306 chkmem->storesize = 0;
1307 chkmem->lazyfreesize = 0;
1308 chkmem->eagerfreesize = 0;
1309 chkmem->initchunksize = initchunksize;
1310 chkmem->garbagefactor = garbagefactor;
1312 chkmem->filename =
NULL;
1314 chkmem->ngarbagecalls = 0;
1315 chkmem->ngarbagefrees = 0;
1318 if( memsize !=
NULL )
1333 assert(chkmem !=
NULL);
1336 for( i = 0; i < chkmem->nchunks; ++i )
1339 chkmem->lazyfree =
NULL;
1340 chkmem->firsteager =
NULL;
1341 chkmem->nchunks = 0;
1342 chkmem->lastchunksize = 0;
1343 chkmem->storesize = 0;
1344 chkmem->lazyfreesize = 0;
1345 chkmem->eagerfreesize = 0;
1355 assert(chkmem !=
NULL);
1356 assert(*chkmem !=
NULL);
1365 if( memsize !=
NULL )
1366 (*memsize) -= (
long long)((
sizeof(
BMS_CHKMEM) + (*chkmem)->chunkssize *
sizeof(
CHUNK*)));
1380 assert(chkmem !=
NULL);
1383 if( chkmem->lazyfree ==
NULL )
1385 assert(chkmem->lazyfreesize == 0);
1388 if( chkmem->firsteager !=
NULL )
1397 assert(chkmem->lazyfree !=
NULL);
1398 assert(chkmem->lazyfreesize > 0);
1400 ptr = chkmem->lazyfree;
1401 chkmem->lazyfree = ptr->next;
1402 chkmem->lazyfreesize--;
1422 assert(chkmem !=
NULL);
1424 debugMessage(
"garbage collection for chunk block %p [elemsize: %d]\n", (
void*)chkmem, chkmem->elemsize);
1427 if( chkmem->lazyfreesize + chkmem->eagerfreesize == chkmem->storesize )
1434 chkmem->ngarbagecalls++;
1438 while( chkmem->lazyfree !=
NULL )
1441 lazyfree = chkmem->lazyfree;
1442 chkmem->lazyfree = chkmem->lazyfree->next;
1443 chkmem->lazyfreesize--;
1446 chunk =
findChunk(chkmem, (
void*)lazyfree);
1450 errorMessage(
"chunk for lazy free chunk %p not found in chunk block %p\n", (
void*)lazyfree, (
void*)chkmem);
1453 assert(chunk !=
NULL);
1457 assert(chunk->eagerfreesize > 0);
1459 assert(chkmem->lazyfreesize == 0);
1462 chunk = chkmem->firsteager;
1463 while( chunk !=
NULL && chkmem->nchunks > 1 )
1465 nexteager = chunk->nexteager;
1466 if( chunk->eagerfreesize == chunk->storesize )
1469 chkmem->ngarbagefrees++;
1485 const char* filename,
1489 assert(chkmem !=
NULL);
1490 assert(ptr !=
NULL);
1492 #if ( defined(CHECKMEM) || defined(CHECKCHKFREE) ) 1497 printError(
"Pointer %p does not belong to chunk block %p (size: %d).\n", ptr, chkmem, chkmem->elemsize);
1502 ((
FREELIST*)ptr)->next = chkmem->lazyfree;
1504 chkmem->lazyfreesize++;
1507 if( chkmem->garbagefactor >= 0 && chkmem->nchunks > 0 && chkmem->lazyfreesize >=
GARBAGE_SIZE 1508 && chkmem->lazyfreesize + chkmem->eagerfreesize
1509 > chkmem->garbagefactor * (
double)(chkmem->storesize) / (
double)(chkmem->nchunks) )
1523 const char* filename,
1531 if( chkmem ==
NULL )
1534 printError(
"Insufficient memory for chunk block.\n");
1536 debugMessage(
"created chunk memory %p [elemsize: %d]\n", (
void*)chkmem, (
int)size);
1544 const char* filename,
1548 debugMessage(
"clearing chunk memory %p [elemsize: %d]\n", (
void*)chkmem, chkmem->elemsize);
1550 if( chkmem !=
NULL )
1555 printError(
"Tried to clear null chunk block.\n");
1562 const char* filename,
1566 assert(chkmem !=
NULL);
1568 debugMessage(
"destroying chunk memory %p [elemsize: %d]\n", (
void*)*chkmem, (*chkmem)->elemsize);
1570 if( *chkmem !=
NULL )
1575 printError(
"Tried to destroy null chunk block.\n");
1583 const char* filename,
1589 assert(chkmem !=
NULL);
1590 assert((
int)size == chkmem->elemsize);
1597 printError(
"Insufficient memory for new chunk.\n");
1599 debugMessage(
"alloced %8llu bytes in %p [%s:%d]\n", (
unsigned long long)size, (
void*)ptr, filename, line);
1611 const char* filename,
1617 assert(chkmem !=
NULL);
1618 assert(source !=
NULL);
1619 assert((
int)size == chkmem->elemsize);
1633 const char* filename,
1637 assert(chkmem !=
NULL);
1638 assert((
int)size == chkmem->elemsize);
1639 assert( ptr !=
NULL );
1643 debugMessage(
"free %8d bytes in %p [%s:%d]\n", chkmem->elemsize, *ptr, filename, line);
1653 printError(
"Tried to free null chunk pointer.\n");
1662 const char* filename,
1666 assert(chkmem !=
NULL);
1667 assert((
int)size == chkmem->elemsize);
1668 assert( ptr !=
NULL );
1672 debugMessage(
"free %8d bytes in %p [%s:%d]\n", chkmem->elemsize, *ptr, filename, line);
1686 debugMessage(
"garbage collection on chunk memory %p [elemsize: %d]\n", (
void*)chkmem, chkmem->elemsize);
1696 assert(chkmem !=
NULL);
1698 return ((
long long)(chkmem->elemsize) * (
long long)(chkmem->storesize));
1724 long long tmpmemalloc = 0LL;
1725 long long tmpmemused = 0LL;
1728 assert(blkmem !=
NULL);
1729 assert(blkmem->chkmemhash !=
NULL);
1733 chkmem = blkmem->chkmemhash[i];
1734 while( chkmem !=
NULL )
1737 tmpmemalloc += ((chkmem->elemsize * chkmem->storesize) + chkmem->nchunks *
sizeof(
CHUNK) +
sizeof(
BMS_CHKMEM)
1738 + chkmem->chunkssize *
sizeof(
CHUNK*));
1739 tmpmemused += (chkmem->elemsize * (chkmem->storesize - chkmem->eagerfreesize - chkmem->lazyfreesize));
1740 chkmem = chkmem->nextchkmem;
1743 assert(tmpmemalloc == blkmem->memallocated);
1744 assert(tmpmemused == blkmem->memused);
1747 #define checkBlkmem(blkmem) 1765 assert(blkmem !=
NULL);
1770 chkmem = blkmem->chkmemhash[i];
1772 chkmem = chkmem->nextchkmem;
1787 return (
int) (((uint32_t)size * UINT32_C(0x9e3779b9))>>(32-
CHKHASH_POWER));
1795 const char* filename,
1803 if( blkmem !=
NULL )
1806 blkmem->chkmemhash[i] =
NULL;
1807 blkmem->initchunksize = initchunksize;
1808 blkmem->garbagefactor = garbagefactor;
1809 blkmem->memused = 0;
1810 blkmem->memallocated = 0;
1811 blkmem->maxmemused = 0;
1812 blkmem->maxmemunused = 0;
1813 blkmem->maxmemallocated = 0;
1818 printError(
"Insufficient memory for block memory header.\n");
1827 const char* filename,
1835 if( blkmem !=
NULL )
1839 chkmem = blkmem->chkmemhash[i];
1840 while( chkmem !=
NULL )
1842 nextchkmem = chkmem->nextchkmem;
1844 chkmem = nextchkmem;
1846 blkmem->chkmemhash[i] =
NULL;
1848 blkmem->memused = 0;
1849 assert(blkmem->memallocated == 0);
1854 printError(
"Tried to clear null block memory.\n");
1861 const char* filename,
1865 assert(blkmem !=
NULL);
1867 if( *blkmem !=
NULL )
1871 assert(*blkmem ==
NULL);
1876 printError(
"Tried to destroy null block memory.\n");
1885 const char* filename,
1893 assert( blkmem !=
NULL );
1900 chkmemptr = &(blkmem->chkmemhash[hashnumber]);
1901 while( *chkmemptr !=
NULL && (*chkmemptr)->elemsize != (
int)size )
1902 chkmemptr = &((*chkmemptr)->nextchkmem);
1905 if( *chkmemptr ==
NULL )
1907 *chkmemptr =
createChkmem((
int)size, blkmem->initchunksize, blkmem->garbagefactor, &blkmem->memallocated);
1908 if( *chkmemptr ==
NULL )
1911 printError(
"Insufficient memory for chunk block.\n");
1916 (*chkmemptr)->line = line;
1926 printError(
"Insufficient memory for new chunk.\n");
1928 debugMessage(
"alloced %8llu bytes in %p [%s:%d]\n", (
unsigned long long)size, ptr, filename, line);
1931 blkmem->memused += (
long long) size;
1932 blkmem->maxmemused =
MAX(blkmem->maxmemused, blkmem->memused);
1933 blkmem->maxmemunused =
MAX(blkmem->maxmemunused, blkmem->memallocated - blkmem->memused);
1934 blkmem->maxmemallocated =
MAX(blkmem->maxmemallocated, blkmem->memallocated);
1936 assert(blkmem->memused >= 0);
1937 assert(blkmem->memallocated >= 0);
1948 const char* filename,
1969 const char* filename,
1990 const char* filename,
2009 const char* filename,
2017 assert(oldsize == 0);
2032 if( oldsize == newsize )
2036 if( newptr !=
NULL )
2050 const char* filename,
2058 assert(oldnum == 0);
2071 if ( oldnum == newnum )
2075 if ( newptr !=
NULL )
2087 const char* filename,
2093 assert(source !=
NULL);
2108 const char* filename,
2114 assert(source !=
NULL);
2129 const char* filename,
2136 assert(ptr !=
NULL);
2137 assert(*ptr !=
NULL);
2143 debugMessage(
"free %8llu bytes in %p [%s:%d]\n", (
unsigned long long)size, *ptr, filename, line);
2146 assert( blkmem->chkmemhash !=
NULL );
2147 chkmem = blkmem->chkmemhash[hashnumber];
2148 while( chkmem !=
NULL && chkmem->elemsize != (
int)size )
2149 chkmem = chkmem->nextchkmem;
2150 if( chkmem ==
NULL )
2153 printError(
"Tried to free pointer <%p> in block memory <%p> of unknown size %llu.\n", *ptr, (
void*)blkmem, (
unsigned long long)size);
2156 assert(chkmem->elemsize == (
int)size);
2160 blkmem->memused -= (
long long) size;
2162 blkmem->maxmemunused =
MAX(blkmem->maxmemunused, blkmem->memallocated - blkmem->memused);
2164 assert(blkmem->memused >= 0);
2165 assert(blkmem->memallocated >= 0);
2177 const char* filename,
2181 assert( blkmem !=
NULL );
2182 assert( ptr !=
NULL );
2186 else if( size != 0 )
2189 printError(
"Tried to free null block pointer.\n");
2199 const char* filename,
2203 assert( blkmem !=
NULL );
2204 assert( ptr !=
NULL );
2222 assert(blkmem !=
NULL);
2228 chkmemptr = &blkmem->chkmemhash[i];
2229 while( *chkmemptr !=
NULL )
2233 if( (*chkmemptr)->nchunks == 0 )
2237 assert((*chkmemptr)->lazyfreesize == 0);
2238 nextchkmem = (*chkmemptr)->nextchkmem;
2240 *chkmemptr = nextchkmem;
2244 chkmemptr = &(*chkmemptr)->nextchkmem;
2254 assert( blkmem !=
NULL );
2256 return blkmem->memallocated;
2264 assert( blkmem !=
NULL );
2266 return blkmem->memused;
2274 assert( blkmem !=
NULL );
2276 return blkmem->memallocated - blkmem->memused;
2284 assert( blkmem !=
NULL );
2286 return blkmem->maxmemused;
2294 assert( blkmem !=
NULL );
2296 return blkmem->maxmemunused;
2304 assert( blkmem !=
NULL );
2306 return blkmem->maxmemallocated;
2317 assert(blkmem !=
NULL);
2323 if( chkmem ==
NULL )
2326 return (
size_t)(chkmem->elemsize);
2336 int nunusedblocks = 0;
2337 int totalnchunks = 0;
2338 int totalneagerchunks = 0;
2339 int totalnelems = 0;
2340 int totalneagerelems = 0;
2341 int totalnlazyelems = 0;
2343 int totalngarbagecalls = 0;
2344 int totalngarbagefrees = 0;
2346 long long allocedmem = 0;
2347 long long freemem = 0;
2352 printInfo(
" ElSize #Chunk #Eag #Elems #EagFr #LazFr #GCl #GFr Free MBytes First Allocator\n");
2354 printInfo(
" ElSize #Chunk #Eag #Elems #EagFr #LazFr Free MBytes\n");
2357 assert(blkmem !=
NULL);
2361 chkmem = blkmem->chkmemhash[i];
2362 while( chkmem !=
NULL )
2367 int neagerchunks = 0;
2368 int neagerelems = 0;
2370 for( c = 0; c < chkmem->nchunks; ++c )
2372 chunk = chkmem->chunks[c];
2373 assert(chunk !=
NULL);
2374 assert(chunk->elemsize == chkmem->elemsize);
2375 assert(chunk->chkmem == chkmem);
2377 nelems += chunk->storesize;
2378 if( chunk->eagerfree !=
NULL )
2381 neagerelems += chunk->eagerfreesize;
2385 assert(nchunks == chkmem->nchunks);
2386 assert(nelems == chkmem->storesize);
2387 assert(neagerelems == chkmem->eagerfreesize);
2392 allocedmem += (
long long)chkmem->elemsize * (
long long)nelems;
2393 freemem += (
long long)chkmem->elemsize * ((
long long)neagerelems + (
long long)chkmem->lazyfreesize);
2396 printInfo(
"%7d %6d %4d %7d %7d %7d %5d %4d %5.1f%% %6.1f %s:%d\n",
2397 chkmem->elemsize, nchunks, neagerchunks, nelems,
2398 neagerelems, chkmem->lazyfreesize, chkmem->ngarbagecalls, chkmem->ngarbagefrees,
2399 100.0 * (
double) (neagerelems + chkmem->lazyfreesize) / (
double) (nelems),
2400 (
double)chkmem->elemsize * nelems / (1024.0*1024.0),
2401 chkmem->filename, chkmem->line);
2403 printInfo(
"%7d %6d %4d %7d %7d %7d %5.1f%% %6.1f\n",
2404 chkmem->elemsize, nchunks, neagerchunks, nelems,
2405 neagerelems, chkmem->lazyfreesize,
2406 100.0 * (
double) (neagerelems + chkmem->lazyfreesize) / (
double) (nelems),
2407 (
double)chkmem->elemsize * nelems / (1024.0*1024.0));
2413 printInfo(
"%7d <unused> %5d %4d %s:%d\n",
2414 chkmem->elemsize, chkmem->ngarbagecalls, chkmem->ngarbagefrees,
2415 chkmem->filename, chkmem->line);
2417 printInfo(
"%7d <unused>\n", chkmem->elemsize);
2421 totalnchunks += nchunks;
2422 totalneagerchunks += neagerchunks;
2423 totalnelems += nelems;
2424 totalneagerelems += neagerelems;
2425 totalnlazyelems += chkmem->lazyfreesize;
2427 totalngarbagecalls += chkmem->ngarbagecalls;
2428 totalngarbagefrees += chkmem->ngarbagefrees;
2430 chkmem = chkmem->nextchkmem;
2434 printInfo(
" Total %6d %4d %7d %7d %7d %5d %4d %5.1f%% %6.1f\n",
2435 totalnchunks, totalneagerchunks, totalnelems, totalneagerelems, totalnlazyelems,
2436 totalngarbagecalls, totalngarbagefrees,
2437 totalnelems > 0 ? 100.0 * (
double) (totalneagerelems + totalnlazyelems) / (
double) (totalnelems) : 0.0,
2438 (
double)allocedmem/(1024.0*1024.0));
2440 printInfo(
" Total %6d %4d %7d %7d %7d %5.1f%% %6.1f\n",
2441 totalnchunks, totalneagerchunks, totalnelems, totalneagerelems, totalnlazyelems,
2442 totalnelems > 0 ? 100.0 * (
double) (totalneagerelems + totalnlazyelems) / (
double) (totalnelems) : 0.0,
2443 (
double)allocedmem/(1024.0*1024.0));
2446 nblocks + nunusedblocks, nunusedblocks, allocedmem, freemem);
2447 if( allocedmem > 0 )
2448 printInfo(
" (%.1f%%)", 100.0 * (
double) freemem / (
double) allocedmem);
2451 printInfo(
"Memory Peaks: Used Lazy Total\n");
2452 printInfo(
" %6.1f %6.1f %6.1f MBytes\n", (
double)blkmem->maxmemused / (1024.0 * 1024.0),
2453 (
double)blkmem->maxmemunused / (1024.0 * 1024.0), (
double)blkmem->maxmemallocated / (1024.0 * 1024.0));
2462 long long allocedmem = 0;
2463 long long freemem = 0;
2467 assert(blkmem !=
NULL);
2471 chkmem = blkmem->chkmemhash[i];
2472 while( chkmem !=
NULL )
2477 int neagerelems = 0;
2479 for( c = 0; c < chkmem->nchunks; ++c )
2481 chunk = chkmem->chunks[c];
2482 assert(chunk !=
NULL);
2483 assert(chunk->elemsize == chkmem->elemsize);
2484 assert(chunk->chkmem == chkmem);
2486 nelems += chunk->storesize;
2487 if( chunk->eagerfree !=
NULL )
2488 neagerelems += chunk->eagerfreesize;
2491 assert(nchunks == chkmem->nchunks);
2492 assert(nelems == chkmem->storesize);
2493 assert(neagerelems == chkmem->eagerfreesize);
2497 allocedmem += (
long long)chkmem->elemsize * (
long long)nelems;
2498 freemem += (
long long)chkmem->elemsize * ((
long long)neagerelems + (
long long)chkmem->lazyfreesize);
2500 if( nelems != neagerelems + chkmem->lazyfreesize )
2504 (((
long long)nelems - (
long long)neagerelems) - (
long long)chkmem->lazyfreesize)
2505 * (
long long)(chkmem->elemsize),
2506 (nelems - neagerelems) - chkmem->lazyfreesize, (
long long)(chkmem->elemsize),
2507 chkmem->filename, chkmem->line);
2509 errorMessage(
"%" LONGINT_FORMAT
" bytes (%d elements of size %" LONGINT_FORMAT
") not freed.\n",
2510 ((nelems - neagerelems) - chkmem->lazyfreesize) * (
long long)(chkmem->elemsize),
2511 (nelems - neagerelems) - chkmem->lazyfreesize, (
long long)(chkmem->elemsize));
2515 chkmem = chkmem->nextchkmem;
2519 if( allocedmem != freemem )
2524 return allocedmem - freemem;
2555 double arraygrowfac,
2558 const char* filename,
2564 assert( arraygrowinit > 0 );
2565 assert( arraygrowfac > 0.0 );
2568 if ( buffer !=
NULL )
2574 buffer->
clean = clean;
2583 printError(
"Insufficient memory for buffer memory header.\n");
2592 const char* filename,
2598 if ( *buffer !=
NULL )
2600 i = (*buffer)->ndata;
2604 assert( ! (*buffer)->used[i] );
2618 printError(
"Tried to free null buffer memory.\n");
2628 assert( buffer !=
NULL );
2629 assert( arraygrowfac > 0.0 );
2640 assert( buffer !=
NULL );
2641 assert( arraygrowinit > 0 );
2646 #ifndef SCIP_NOBUFFERMEM 2660 assert( growfac >= 1.0 );
2662 if ( growfac == 1.0 )
2663 size =
MAX(initsize, num);
2669 initsize =
MAX(initsize, 4);
2674 while ( size < num && size > oldsize )
2677 size = (size_t)(growfac * size + initsize);
2681 if ( size <= oldsize )
2685 assert( size >= initsize );
2686 assert( size >= num );
2697 const char* filename,
2702 #ifndef SCIP_NOBUFFERMEM 2706 #ifndef SCIP_NOBUFFERMEM 2707 assert( buffer !=
NULL );
2726 printError(
"Insufficient memory for reallocating buffer data storage.\n");
2733 printError(
"Insufficient memory for reallocating buffer size storage.\n");
2740 printError(
"Insufficient memory for reallocating buffer used storage.\n");
2745 for (i = buffer->
ndata; i < newsize; ++i)
2748 buffer->
size[i] = 0;
2751 buffer->
ndata = newsize;
2757 assert( ! buffer->
used[bufnum] );
2758 if ( buffer->
size[bufnum] < size )
2769 char* tmpptr = (
char*)(buffer->
data[bufnum]);
2770 size_t inc = buffer->
size[bufnum] /
sizeof(*tmpptr);
2775 assert( newsize > buffer->
size[bufnum] );
2777 buffer->
size[bufnum] = newsize;
2779 if ( buffer->
data[bufnum] ==
NULL )
2782 printError(
"Insufficient memory for reallocating buffer storage.\n");
2786 assert( buffer->
size[bufnum] >= size );
2792 char* tmpptr = (
char*)(buffer->
data[bufnum]);
2793 unsigned int inc = buffer->
size[bufnum] /
sizeof(*tmpptr);
2796 while( --tmpptr >= (
char*)(buffer->
data[bufnum]) )
2797 assert(*tmpptr ==
'\0');
2801 ptr = buffer->
data[bufnum];
2805 debugMessage(
"Allocated buffer %llu/%llu at %p of size %llu (required size: %llu) for pointer %p.\n",
2806 (
unsigned long long)bufnum, (
unsigned long long)(buffer->
ndata), buffer->
data[bufnum],
2807 (
unsigned long long)(buffer->
size[bufnum]), (
unsigned long long)size, ptr);
2827 const char* filename,
2848 const char* filename,
2869 const char* filename,
2888 const char* filename,
2893 #ifndef SCIP_NOBUFFERMEM 2897 #ifndef SCIP_NOBUFFERMEM 2898 assert( buffer !=
NULL );
2900 assert(!buffer->
clean);
2913 while ( bufnum > 0 && buffer->
data[bufnum] != ptr )
2917 assert( buffer->
data[bufnum] == newptr );
2918 assert( buffer->
used[bufnum] );
2919 assert( buffer->
size[bufnum] >= 1 );
2922 if ( size > buffer->
size[bufnum] )
2929 assert( newsize > buffer->
size[bufnum] );
2931 buffer->
size[bufnum] = newsize;
2932 if ( buffer->
data[bufnum] ==
NULL )
2935 printError(
"Insufficient memory for reallocating buffer storage.\n");
2938 newptr = buffer->
data[bufnum];
2940 assert( buffer->
size[bufnum] >= size );
2941 assert( newptr == buffer->
data[bufnum] );
2943 debugMessage(
"Reallocated buffer %llu/%llu at %p to size %llu (required size: %llu) for pointer %p.\n",
2944 (
unsigned long long)bufnum, (
unsigned long long)(buffer->
ndata), buffer->
data[bufnum],
2945 (
unsigned long long)(buffer->
size[bufnum]), (
unsigned long long)size, newptr);
2960 const char* filename,
2982 const char* filename,
3003 const char* filename,
3009 assert( source !=
NULL );
3027 const char* filename,
3033 assert( source !=
NULL );
3050 const char* filename,
3056 assert( buffer !=
NULL );
3059 assert( ptr !=
NULL );
3060 assert( *ptr !=
NULL );
3067 while ( bufnum > 0 && buffer->
data[bufnum] != *ptr )
3070 #ifdef CHECKBUFFERORDER 3071 if ( bufnum < buffer->firstfree - 1 )
3073 warningMessage(
"[%s:%d]: freeing buffer in wrong order.\n", filename, line);
3078 if ( bufnum == 0 && buffer->
data[bufnum] != *ptr )
3081 printError(
"Tried to free unkown buffer pointer.\n");
3084 if ( ! buffer->
used[bufnum] )
3087 printError(
"Tried to free buffer pointer already freed.\n");
3096 char* tmpptr = (
char*)(buffer->
data[bufnum]);
3097 unsigned int inc = buffer->
size[bufnum] /
sizeof(*tmpptr);
3100 while( --tmpptr >= (
char*)(buffer->
data[bufnum]) )
3101 assert(*tmpptr ==
'\0');
3105 assert( buffer->
data[bufnum] == *ptr );
3111 debugMessage(
"Freed buffer %llu/%llu at %p of size %llu for pointer %p, first free is %llu.\n",
3112 (
unsigned long long)bufnum, (
unsigned long long)(buffer->
ndata), buffer->
data[bufnum],
3113 (
unsigned long long)(buffer->
size[bufnum]), *ptr, (
unsigned long long)(buffer->
firstfree));
3122 const char* filename,
3126 assert( ptr !=
NULL );
3128 #ifndef SCIP_NOBUFFERMEM 3134 printError(
"Tried to free null buffer pointer.\n");
3145 const char* filename,
3149 assert( ptr !=
NULL );
3153 #ifndef SCIP_NOBUFFERMEM 3166 assert( buffer !=
NULL );
3177 size_t totalmem = 0UL;
3180 assert( buffer !=
NULL );
3181 for (i = 0; i < buffer->
ndata; ++i)
3182 totalmem += buffer->
size[i];
3183 assert( totalmem == buffer->
totalmem );
3186 return (
long long) buffer->
totalmem;
3197 assert( buffer !=
NULL );
3200 for (i = 0; i < buffer->
ndata; ++i)
3202 printf(
"[%c] %8llu bytes at %p\n", buffer->
used[i] ?
'*' :
' ', (
unsigned long long)(buffer->
size[i]), buffer->
data[i]);
3203 totalmem += buffer->
size[i];
3205 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)
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 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)
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)
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 int linkChunk(BMS_CHKMEM *chkmem, CHUNK *chunk, 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)
static void alignSize(size_t *size)
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)
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)
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)
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
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