memory: reduce heap Rss size around 3M
PATCH v2 1/1 memory: reduce heap Rss size around 3M
Since cpu-memory and memory have same address space,one malloced memory is enough. This patch will skip memory malloc for memory address space,which will reduce around 3M physical memory in heap.
--- memory.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
memory.c +1 -1
@@ -2422,7 +2422,7 @@ AddressSpace *address_space_init_shareable(MemoryRegion *root, const char *name)AddressSpace *as; QTAILQ_FOREACH(as, &address_spaces, address_spaces_link) { -if (root == as->root && as->malloced) { +if (root == as->root) { as->ref_count++;return as; }
Signature · 1 line
1.9.1
Quoted 15 lines · Yang Zhong
Since cpu-memory and memory have same address space,one malloced memory is enough. This patch will skip memory malloc for memory address space,which will reduce around 3M physical memory in heap.
Signed-off-by Yang Zhong <[email protected]>--- memory.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)memory.c +0
-0
memory.c AddressSpace *address_space_init_shareable(MemoryRegion *root, const char *name) · line 2428
Quoted 8 lines
memory.c +1
-1@@ -2422,7 +2422,7 @@ AddressSpace *address_space_init_shareable(MemoryRegion *root, const char *name)AddressSpace *as; QTAILQ_FOREACH(as, &address_spaces, address_spaces_link) { -if (root == as->root && as->malloced) { +if (root == as->root) { as->ref_count++;return as; }
This has the same problem as v1.
If as->malloced is false, the AddressSpace might be embedded in another struct. This other struct could be freed when as->ref_count is still greater than 0, causing a use-after-free bug.
Paolo