mirror of
https://github.com/GOSTSec/sgminer
synced 2025-01-29 16:04:33 +00:00
Only keep the last 6 blocks in the uthash database to keep memory usage constant. Storing more is unhelpful anyway.
This commit is contained in:
parent
f7f55e777d
commit
0feb679b67
14
cgminer.c
14
cgminer.c
@ -2858,6 +2858,20 @@ static void test_work_current(struct work *work)
|
|||||||
quit (1, "test_work_current OOM");
|
quit (1, "test_work_current OOM");
|
||||||
strcpy(s->hash, hexstr);
|
strcpy(s->hash, hexstr);
|
||||||
wr_lock(&blk_lock);
|
wr_lock(&blk_lock);
|
||||||
|
/* Only keep the last 6 blocks in memory since work from blocks
|
||||||
|
* before this is virtually impossible and we want to prevent
|
||||||
|
* memory usage from continually rising */
|
||||||
|
if (HASH_COUNT(blocks) > 5) {
|
||||||
|
struct block *blocka, *blockb;
|
||||||
|
int count = 0;
|
||||||
|
|
||||||
|
HASH_ITER(hh, blocks, blocka, blockb) {
|
||||||
|
if (count++ < 6)
|
||||||
|
continue;
|
||||||
|
HASH_DEL(blocks, blocka);
|
||||||
|
free(blocka);
|
||||||
|
}
|
||||||
|
}
|
||||||
HASH_ADD_STR(blocks, hash, s);
|
HASH_ADD_STR(blocks, hash, s);
|
||||||
wr_unlock(&blk_lock);
|
wr_unlock(&blk_lock);
|
||||||
set_curblock(hexstr, work->data);
|
set_curblock(hexstr, work->data);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user