I have a UVM tb that keeps increasing memory usage the longer I run it. The test does finish. I have determined the leak to come from the driver because when I test it without driving an item, only generating it, the memory usage is very small. This turns into issues when I run larger tests as it crashes the computer.
I have tested commenting out the monitor thinking maybe that is the issue but the memory usage is the same. So that has led me to believe it is the driver causing the memory issue.
Below is my drive_item from my driver.
virtual task drive_item(Item_in m_item);
if (dut_in1.rst_n) begin
@(posedge dut_in1.clk);
dut_in1.data <= 'x;
dut_in1.empty_b <= 'x;
dut_in1.valid <= 0;
dut_in1.eop <= 0;
dut_in1.sop <= 0;
empty = (DATA_BYTES - (m_item.data_in.size() % DATA_BYTES));
count = 0;
do begin
if (!dut_in1.valid | dut_in1.ready) begin
if (count + DATA_BYTES >= m_item.data_in.size()) begin
dut_in1.eop <= 1;
if (contains(my_name, "dma_in") | contains(my_name, "tcp_in")) begin
flag = 0;
dut_in1.error_r <= 1'b0;
end else begin
flag = m_item.error_r ? 1 : 0;
dut_in1.error_r <= m_item.error_r;
end
end else begin
dut_in1.eop <= 0;
dut_in1.error_r <= 0;
flag = 0;
end
dut_in1.session_id_in = m_item.session_id;
dut_in1.sop <= (count == 0);
dut_in1.empty_b <= (count + (m_item.data_in.size() % DATA_BYTES) >= m_item.data_in.size()) ? empty : 0;
dut_in1.valid <= 1;
dut_in1.payload_size <= m_item.data_in.size();
for (int i = 0; i < DATA_BYTES; i++) begin
if (count < m_item.data_in.size()) begin
dut_in1.data[(DATA_BYTES*8-1)-(8*i)-:8] <= flag ? 'X : m_item.data_in[count];
count += 1;
end
end
end
@(posedge dut_in1.clk);
end while (!(dut_in1.ready & dut_in1.valid & dut_in1.eop));
m_item.data_in.delete(); //Added this thinking maybe its because the data isn't being deleted.
dut_in1.empty_b <= 'x;
dut_in1.valid <= 0;
dut_in1.eop <= 0;
dut_in1.sop <= 0;
dut_in1.payload_size <= 'x;
end else begin
@(posedge dut_in1.clk);
end
endtask```