Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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...
commit 8b8d57303025367b8dbff525491f281515791466 1 parent c31eb51
Andreas Sandberg authored

Showing 2 changed files with 4 additions and 1 deletion. Show diff stats Hide diff stats

  1. +3 0  src/mem/simple_dram.cc
  2. +1 1  src/mem/simple_dram.hh
3  src/mem/simple_dram.cc
@@ -449,6 +449,8 @@ SimpleDRAM::addToWriteQueue(PacketPtr pkt)
449 449 bytesConsumedWr += pkt->getSize();
450 450 bytesWritten += bytesPerCacheLine;
451 451 accessAndRespond(pkt);
  452 + if (!pkt->needsResponse())
  453 + dram_pkt->pkt = NULL;
452 454
453 455 // If your write buffer is starting to fill up, drain it!
454 456 if (writeQueue.size() > writeThreshold && !stopReads){
@@ -739,6 +741,7 @@ SimpleDRAM::accessAndRespond(PacketPtr pkt)
739 741 // next tick
740 742 port.schedTimingResp(pkt, curTick() + 1);
741 743 } else {
  744 + pendingDelete.push_back(pkt);
742 745 }
743 746
744 747 DPRINTF(DRAM, "Done\n");
2  src/mem/simple_dram.hh
@@ -167,7 +167,7 @@ class SimpleDRAM : public AbstractMemory
167 167 Tick readyTime;
168 168
169 169 /** This comes from the outside world */
170   - const PacketPtr pkt;
  170 + PacketPtr pkt;
171 171
172 172 /** Will be populated by address decoder */
173 173 const uint8_t rank;

0 comments on commit 8b8d573

Please sign in to comment.
Something went wrong with that request. Please try again.