[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ns] Memory issue in ns
Hi everybody,
I am having a memory problem in ns and I wanted to ask if
anybody has some insight to this. I am using the b6 release
version of ns to develop some wireless simulations on Red Hat Linux.
Here is what I am trying to do.
I am creating a c++ object and I pass a pointer to the DSDV
instance of each node inside the dsdv.tcl files. (My object is
created and initialized in my simulation file.
At the routing layer I have another algorithm that runs in parallel
to DSDV. This algorithm has its own class, myclass and it is created
inside the DSDV_Agent::startUp() function.
I use this object to collect differnt statistics for each of the
nodes in my simulation so I maintain a structure like this:
typedef struct poNodeAttr{
double rx_bytecount_;
double dest_rx_bytecount_;
double tx_bytecount_;
int loc_beacon_;
};
in the constructor of my class I allocate one structure for each node:
node_attr_ = (poNodeAttr*)malloc(node_count_ * sizeof(poNodeAttr));
During the simulation I read and write to this structure through a set of
set of functions. This works fine for my simulation setup which consists
of 100 nodes.
OK, now here is the problem:
When I try to extend my structure to
typedef struct poNodeAttr{
double rx_bytecount_;
double dest_rx_bytecount_;
double tx_bytecount_;
int loc_beacon_;
myclass* myclass_;
};
my simulation seg faults at different places depending on the number of
nodes I use. I am pretty sure that this is memory related since I do not
have problem using it with small simulations.
To generalize it more, this problem occurs for amy call to malloc that
requires a large chunck of memory. The simulation will not die immediately
after the call to malloc but it will segfault at some other point when it
tries to access some part of the memory that appears be corrupted by
malloc.
I couldn't get to the bottom of this using gdb. I am now in the process of
installing dmalloc to try to trace this down but the problem seems to be
pretty deep in tcl. Does anybody have an idea or previous experience with
something like this? Am I doing something wrong here?
Thanks,
Andreas
[email protected]
PS: My PC has 256MB of RAM and ulimit = unlimited