mirror of
https://github.com/netsurf-browser/netsurf
synced 2025-01-17 08:09:20 +03:00
Add low memory handler to purge unused slabs on OS3
TODO: find some way to purge NetSurf's memory cache safely from another process
This commit is contained in:
parent
2043223788
commit
c4b8857789
@ -5543,6 +5543,11 @@ int main(int argc, char** argv)
|
||||
/* Open splash window */
|
||||
Object *splash_window = ami_gui_splash_open();
|
||||
|
||||
#ifndef __amigaos4__
|
||||
/* OS3 low memory handler */
|
||||
struct Interupt *memhandler = ami_memory_init();
|
||||
#endif
|
||||
|
||||
ami_object_init();
|
||||
|
||||
if (ami_open_resources() == false) { /* alloc message ports */
|
||||
@ -5743,6 +5748,11 @@ int main(int argc, char** argv)
|
||||
ami_object_fini();
|
||||
ami_bitmap_fini();
|
||||
|
||||
#ifndef __amigaos4__
|
||||
/* OS3 low memory handler */
|
||||
ami_memory_fini(memhandler);
|
||||
#endif
|
||||
|
||||
LOG("Closing screen");
|
||||
ami_gui_close_screen(scrn, locked_screen, FALSE);
|
||||
if(nsscreentitle) FreeVec(nsscreentitle);
|
||||
|
@ -17,8 +17,11 @@
|
||||
*/
|
||||
|
||||
#ifndef __amigaos4__
|
||||
#include <proto/exec.h>
|
||||
#include <exec/interrupts.h>
|
||||
#include <stdlib.h>
|
||||
#include "amiga/memory.h"
|
||||
#include "amiga/os3support.h"
|
||||
#include "utils/log.h"
|
||||
|
||||
ULONG __slab_max_size = 2048; /* Enable clib2's slab allocator */
|
||||
@ -60,5 +63,32 @@ void ami_memory_slab_dump(void)
|
||||
{
|
||||
__get_slab_usage(ami_memory_slab_callback);
|
||||
}
|
||||
|
||||
static ASM ULONG ami_memory_handler(REG(a0, struct MemHandlerData *mhd), REG(a1, void *userdata), REG(a6, struct ExecBase *execbase))
|
||||
{
|
||||
__free_unused_slabs();
|
||||
|
||||
return MEM_ALL_DONE;
|
||||
}
|
||||
|
||||
struct Interrupt *ami_memory_init(void)
|
||||
{
|
||||
struct Interrupt *memhandler = malloc(sizeof(struct Interrupt));
|
||||
|
||||
memhandler->is_Node.ln_Pri = 1;
|
||||
memhandler->is_Node.ln_Name = "NetSurf slab memory handler";
|
||||
memhandler->is_Data = NULL;
|
||||
memhandler->is_Code = (APTR)&ami_memory_handler;
|
||||
AddMemHandler(memhandler);
|
||||
|
||||
return memhandler;
|
||||
}
|
||||
|
||||
void ami_memory_fini(struct Interrupt *memhandler)
|
||||
{
|
||||
RemMemHandler(memhandler);
|
||||
free(memhandler);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -57,9 +57,11 @@ void *ami_memory_clear_alloc(size_t size, UBYTE value);
|
||||
#define ami_memory_itempool_free(p,i,s) FreePooled(p,i,s)
|
||||
#endif
|
||||
|
||||
/* clib2 slab allocator stats */
|
||||
/* clib2 slab allocator */
|
||||
#ifndef __amigaos4__
|
||||
void ami_memory_slab_dump(void);
|
||||
struct Interrupt *ami_memory_init(void);
|
||||
void ami_memory_fini(struct Interrupt *memhandler);
|
||||
#endif
|
||||
|
||||
#endif //AMIGA_MEMORY_H
|
||||
|
Loading…
Reference in New Issue
Block a user