21#include <proto/exec.h>
22#include <exec/interrupts.h>
44 void *mem = malloc(size);
45 if (mem) memset(mem, value, size);
52 if(sui->sui_slab_index <= 1) {
53 NSLOG(netsurf, INFO,
"clib2 slab usage:");
55 " The size of all slabs, in bytes: %ld",
58 " Number of allocations which are not managed by slabs: %ld",
59 sui->sui_num_single_allocations);
61 " Total number of bytes allocated for memory not managed by slabs: %ld",
62 sui->sui_total_single_allocation_size);
64 " Number of slabs currently in play: %ld",
67 " Number of currently unused slabs: %ld",
68 sui->sui_num_empty_slabs);
70 " Number of slabs in use which are completely filled with data: %ld",
71 sui->sui_num_full_slabs);
73 " Total number of bytes allocated for all slabs: %ld",
74 sui->sui_total_slab_allocation_size);
76 NSLOG(netsurf, INFO,
"Slab %d", sui->sui_slab_index);
77 NSLOG(netsurf, INFO,
" Memory chunk size managed by this slab: %ld",
80 " Number of memory chunks that fit in this slab: %ld",
83 " Number of memory chunks used in this slab: %ld",
84 sui->sui_num_chunks_used);
91 if(sai->sai_allocation_index <= 1) {
92 NSLOG(netsurf, INFO,
"clib2 allocation usage:");
94 " Number of allocations which are not managed by slabs: %ld",
95 sai->sai_num_single_allocations);
97 " Total number of bytes allocated for memory not managed by slabs: %ld",
98 sai->sai_total_single_allocation_size);
100 NSLOG(netsurf, INFO,
"Alloc %d", sai->sai_allocation_index);
101 NSLOG(netsurf, INFO,
" Size of this allocation, as requested: %ld",
102 sai->sai_allocation_size);
104 " Total size of this allocation, including management data: %ld",
105 sai->sai_total_allocation_size);
112 BPTR fh = (BPTR)user_data;
113 long err = FPuts(fh,
line);
133 NSLOG(netsurf, INFO,
"Purging llcache");
139 NSLOG(netsurf, INFO,
"Purging unused slabs");
140 __free_unused_slabs();
162 return MEM_TRY_AGAIN;
167 struct Interrupt *memhandler = malloc(
sizeof(
struct Interrupt));
168 if(memhandler == NULL)
return NULL;
170 memhandler->is_Node.ln_Pri = -127;
171 memhandler->is_Node.ln_Name =
"NetSurf low memory handler";
172 memhandler->is_Data = NULL;
174 AddMemHandler(memhandler);
181 if(memhandler != NULL) {
182 RemMemHandler(memhandler);
nserror ami_schedule(int t, void(*callback)(void *p), void *p)
Schedule a callback.
void llcache_clean(bool purge)
Cause the low-level cache to attempt to perform cleanup.
Low-level resource cache (interface)
#define NSLOG(catname, level, logmsg, args...)
void * ami_memory_clear_alloc(size_t size, UBYTE value)
static void ami_memory_low_mem_handler(void *p)
void ami_memory_fini(struct Interrupt *memhandler)
static ASM ULONG ami_memory_handler(REG(a0, struct MemHandlerData *mhd), REG(a1, void *userdata), REG(a6, struct ExecBase *execbase))
static int ami_memory_slab_alloc_cb(const struct __slab_allocation_information *sai)
static int low_mem_status
static int ami_memory_slab_stats_cb(void *user_data, const char *line, size_t line_length)
void ami_memory_slab_dump(BPTR fh)
static int ami_memory_slab_usage_cb(const struct __slab_usage_information *sui)
struct Interrupt * ami_memory_init(void)
Minimal compatibility header for AmigaOS 3.
static nserror line(const struct redraw_context *ctx, const plot_style_t *style, const struct rect *line)
Plots a line.