Permalink
Browse files

mem: Fix memory leak in SimpleDRAM

SimpleDRAM currently does not deallocate packets that don't need a
response. This changeset adds deallocation in
SimpleDRAM::accessAndRespond if a packet does not need a
response. Additionally, it makes the pkt field in DRAMPacket non-const
to allow setting it to NULL when deallocating packets from a write
request.
  • Loading branch information...
1 parent c31eb51 commit 8b8d57303025367b8dbff525491f281515791466 @andysan committed Mar 16, 2013
Showing with 4 additions and 1 deletion.
  1. +3 −0 src/mem/simple_dram.cc
  2. +1 −1 src/mem/simple_dram.hh
@@ -449,6 +449,8 @@ SimpleDRAM::addToWriteQueue(PacketPtr pkt)
bytesConsumedWr += pkt->getSize();
bytesWritten += bytesPerCacheLine;
accessAndRespond(pkt);
+ if (!pkt->needsResponse())
+ dram_pkt->pkt = NULL;
// If your write buffer is starting to fill up, drain it!
if (writeQueue.size() > writeThreshold && !stopReads){
@@ -739,6 +741,7 @@ SimpleDRAM::accessAndRespond(PacketPtr pkt)
// next tick
port.schedTimingResp(pkt, curTick() + 1);
} else {
+ pendingDelete.push_back(pkt);
}
DPRINTF(DRAM, "Done\n");
@@ -167,7 +167,7 @@ class SimpleDRAM : public AbstractMemory
Tick readyTime;
/** This comes from the outside world */
- const PacketPtr pkt;
+ PacketPtr pkt;
/** Will be populated by address decoder */
const uint8_t rank;

0 comments on commit 8b8d573

Please sign in to comment.