Thursday, January 08, 2009     Register | Login | Search | Contact Us
     

Many of you already received communications about the move of the Cadence user community into cadence.com. And many of you have already joined, with over 4000 registrations in the first two weeks.

The new Cadence Community enhances the ability of Cadence users to connect and collaborate. In addition to moving the community into cadence.com -- enabling single sign-on for community, Sourcelink and Cadence events -- the new site is organized around nine technology segments, giving you easy access to product information, training, forums and blogs. Some of the new features include:
  • Ability to respond to posts via e-mail
  • Technology-specific blogs
  • Latest Web 2.0 social networking capabilities
  • Public profile options
  • Private messaging
  • Friends lists
Visit the new Cadence Community today at www.cadence.com/community and join the discussions!

Registration note: Due to the scope of the enhancements and the new SSO registration system, we were not able to migrate existing cdnusers.org member accounts. So new registrations are required, but this enables a broader set of functionality we think you'll enjoy.

Forum note: Under the guidance of forum moderators, we have taken the 20+ cdnusers.org forums and consolidated them into 11 forums on the new site. Posts have been brought over so you can leverage that posting history. CDNusers forums will be set to read only starting 7/30, and cdnusers.org will be redirected to the new community on 8/4.

Best regards,
Mike and Tom

Michael A. Catrambone - Steering Committee Chairman
Distinguished Engineer
PCB/Mechanical
UTStarcom, Inc.

Tom Diederich
Cadence Community Manager
Home
Forums
Subject: memory leak - IUS61 system verilog
Posting to forums is available to community members only.
Login or Register
Rate this topic:
   
Author Messages
vietnguyen
Posts: 1
Online: User is Offline
7/23/2007 2:23 PM  
Hello,

I have a small piece of code that uses the class and mailbox feature of system verilog.  There is a sender task which generates a transactions and puts the transaction handle in a mailbox.  The receiver task waits on a message from the mailbox and when one arrives it reads the message and print a message.  The mailbox is bounded.

The sender and receiver tasks are forked in an initial block.

I seem to be experiencing a memory leak since the heap continues to grow.  My understanding is system verilog handles garbage collection automatically.

What am I doing wrong in my code.  Attached is code:


module mem_leak ();

/////////////////////////////////////////////////////////////////////
// Generate clock and reset
/////////////////////////////////////////////////////////////////////

reg clk;

initial
begin
    clk = 0;
    forever #(10/2) clk = ~clk;
end

/////////////////////////////////////////////////////////////////////
// Class declarations
/////////////////////////////////////////////////////////////////////

class CpuCmd;
    time startT;
    time stopT;
    reg Ώ:0] cpu_id;

    reg btype;
    rand reg wr_rdn;

    rand reg ⎦:0] addr;
    rand reg [ 5:0] size;
    reg ⎳:0] packed_cmdΏ:0]
    reg ⎖:0] total_wd;

    extern task gen_cpu_addr;
    constraint cpucmd_constraint;
endclass

constraint CpuCmd::cpucmd_constraint
{
    addr inside {Ύ : 2000]};
    size inside {1, 4};
}

task CpuCmd::gen_cpu_addr;

    startT    = $time;
    stopT     = startT;
    cpu_id    = 0;

    btype  = 0;

    packed_cmdΎ] = {btype,wr_rdn,3'h0,addr,2'h0,size};
    packed_cmdΏ] = 40'h0;

    total_wd = size;

endtask

/////////////////////////////////////////////////////////////////////
// Declarations
/////////////////////////////////////////////////////////////////////

// Command queue to hold transactions
mailbox cmdQ;

/////////////////////////////////////////////////////////////////////
// Main client loop
/////////////////////////////////////////////////////////////////////

initial
begin
    repeat (20) @(posedge clk);

    cmdQ  = new(4); // bounded mailbox

    repeat (20) @(posedge clk);

    fork
        begin
            $display("INFO: Fork Sender");
            sender;
        end

        begin
            $display("INFO: Fork receiver");
            receiver;
        end
    join
end

///////////////////////////////////////////
// Sender
///////////////////////////////////////////
task sender;

   int val;
   CpuCmd Scmd;

   while (1)
   begin
    repeat (1000) @(posedge clk);

    Scmd = new;

    val = Scmd.randomize();
    if (val == 0)
    begin
        $display("Scmd randomization failed at %0t", $time);
        @(posedge clk);
        $finish;
    end

    Scmd.gen_cpu_addr(); // generate a command

    cmdQ.put(Scmd); // put command into mailbox
    $display("Sent message at %0t", $time);
   end
endtask

///////////////////////////////////////////
// Receiver
///////////////////////////////////////////

task receiver;

   CpuCmd Rcmd;

   while (1)
   begin
           @(posedge clk);
        cmdQ.get(Rcmd); // Get a message from the mailbox
        $display("Received message at %0t", $time);
   end

endtask

endmodule

stephenh
Posts: 77
Online: User is Offline
8/01/2007 10:00 AM  
What exact version of IUS are you using?
I tried running your code on IUS6.11s2 and 6.11s3, but didn't see any sign of increasing memory consumption.
My tests ran for about 1.5h and passed hundreds of thousands of items through the mailbox.

Maximum memory consumption was always 29.3 MB no matter how long the test ran for.


Steve H.
Posting to forums is available to community members only.
Login or Register

Forums > Functional Verification > SystemVerilog > memory leak - IUS61 system verilog


ActiveForums 3.6
     
Copyright 2006 Cadence Design Systems, Inc.