|
@@ -284,6 +284,7 @@ void * alloc_memblock ( size_t size, size_t align, size_t offset ) {
|
284
|
284
|
size_t post_size;
|
285
|
285
|
struct memory_block *pre;
|
286
|
286
|
struct memory_block *post;
|
|
287
|
+ unsigned int discarded;
|
287
|
288
|
void *ptr;
|
288
|
289
|
|
289
|
290
|
/* Sanity checks */
|
|
@@ -371,7 +372,13 @@ void * alloc_memblock ( size_t size, size_t align, size_t offset ) {
|
371
|
372
|
}
|
372
|
373
|
|
373
|
374
|
/* Try discarding some cached data to free up memory */
|
374
|
|
- if ( ! discard_cache() ) {
|
|
375
|
+ DBGC ( &heap, "Attempting discard for %#zx (aligned %#zx+%zx), "
|
|
376
|
+ "used %zdkB\n", size, align, offset, ( usedmem >> 10 ) );
|
|
377
|
+ valgrind_make_blocks_noaccess();
|
|
378
|
+ discarded = discard_cache();
|
|
379
|
+ valgrind_make_blocks_defined();
|
|
380
|
+ check_blocks();
|
|
381
|
+ if ( ! discarded ) {
|
375
|
382
|
/* Nothing available to discard */
|
376
|
383
|
DBGC ( &heap, "Failed to allocate %#zx (aligned "
|
377
|
384
|
"%#zx)\n", size, align );
|