mirror of
https://github.com/corda/corda.git
synced 2025-01-03 19:54:13 +00:00
avoid allocating new memory in hashMapRemove when GCing
This ensures that we don't abort when running an internal finalizer that removes from a hash map.
This commit is contained in:
parent
68c3b241ce
commit
e0ceaa5f43
10
src/util.cpp
10
src/util.cpp
@ -449,6 +449,12 @@ hashMapInsert(Thread* t, object map, object key, object value,
|
||||
|
||||
set(t, n, TripleThird, arrayBody(t, array, index));
|
||||
set(t, array, ArrayBody + (index * BytesPerWord), n);
|
||||
|
||||
if (hashMapSize(t, map) <= arrayLength(t, array) / 3) {
|
||||
// this might happen if nodes were removed during GC in which case
|
||||
// we weren't able to resize at the time
|
||||
hashMapResize(t, map, hash, arrayLength(t, array) / 2);
|
||||
}
|
||||
}
|
||||
|
||||
object
|
||||
@ -495,7 +501,9 @@ hashMapRemove(Thread* t, object map, object key,
|
||||
}
|
||||
}
|
||||
|
||||
if (hashMapSize(t, map) <= arrayLength(t, array) / 3) {
|
||||
if ((not t->m->collecting)
|
||||
and hashMapSize(t, map) <= arrayLength(t, array) / 3)
|
||||
{
|
||||
PROTECT(t, o);
|
||||
hashMapResize(t, map, hash, arrayLength(t, array) / 2);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user