arch-power: Fix memory leaks from address translation gem5-experimental-rebase
authorSandipan Das <sandipan@linux.ibm.com>
Fri, 24 Apr 2020 06:14:33 +0000 (11:44 +0530)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Sun, 24 Jan 2021 04:25:28 +0000 (04:25 +0000)
While performing address translation using the radix tree
walk mechanism, the objects corresponding to the read and
write requests must be freed properly. These contain data
buffers which if not freed, will keep increasing memory
usage and cause the simulator to get OOM-killed quite
early on low-memory systems.

Change-Id: I0bc87bd8950e83829d68ba51e64d81eabf20fa6b
Signed-off-by: Sandipan Das <sandipan@linux.ibm.com>
src/arch/power/radixwalk.cc

index a0e88ed2e21af771f80d4a251a9e119d8897ff35..597ca262fe570eb96a29b3d1b5849e6f73b07bd3 100644 (file)
@@ -78,7 +78,9 @@ RadixWalk::readPhysMem(uint64_t addr, uint64_t dataSize)
     this->port.sendAtomic(read);
     ret = read->get<uint64_t>();
 
+    read->deleteData();
     delete read->req;
+    delete read;
 
     return ret;
 }
@@ -95,7 +97,9 @@ RadixWalk::writePhysMem(uint64_t addr, uint64_t dataSize)
     this->port.sendAtomic(write);
     ret = write->get<uint64_t>();
 
+    write->deleteData();
     delete write->req;
+    delete write;
 
     return ret;
 }