Queue overriding with new item push

Hi All,
in my driver code I’m trying to save my packet class in queue while every time driving.

task drive();
@(posedge vif.hclk)
if(vif.rst==1)
begin
 if(ahb_pkt.hwrite==1)
  begin
    vif.haddr=ahb_pkt.addr;
    vif.hsize=ahb_pkt.size;
    ....
    ....
    vif.hsel=ahb_pkt.sel;
   @(posedge vif.hclk)
    vif.hwdata=ahb_pkt.wdata;
   tx_pkt_q.push_back(ahb_pkt);
  end
 else begin
   vif.haddr=ahb_pkt.addr;
    vif.hsize=ahb_pkt.size;
    ....
    ....
    vif.hsel=ahb_pkt.sel;
   @(posedge vif.hclk)
    ahb_pkt.rdata=vif.hrdata;
    rx_pkt_q.push_back(ahb_pkt); end
end
endtask

task check();
if(tx_pkt_q.size()>0) begin
tx_pkt=tx_pkt_q.pop_front(); end
endtask

from this code, while reading tx_pkt_q and its size I’m observing that queue size is 8 and the data from queue is overring all 8 location with recent push packet. I’m reading queue with pop_front like tx_pkt=tx_pkt_q.pop_front(); so all 8 locations reading with last push packet, overriding previous packets.

Please let me know why this is happening why i’m unable read pervious 7 different packets.
Note: I’m not using UVM, its simple sv tb drive code

In reply to verificationstud:

You are reusing the same ahb_pkt handle. Make sure that you create a new ahb_pkt handle for each transaction.

In reply to cgales:

What modifications I need to do here.

In reply to verificationstud:

Your issue is in a different part of your code. You need to show the entire class.

In reply to verificationstud:

You are not showing the code that constructs a ahb_pkt handle, You need to show enough code that demonstrates a new handle gets constructed for each push_back() executed.