【发布时间】:2017-02-15 15:34:35
【问题描述】:
模拟运行但在控制台中我有这个注释。
未处理的对象:(omnetpp::cMessage) Mysimulation.Switch4.eth[2].queue.scheduler.IntervalTimemsg -- 检查 模块析构函数未处理的对象:(omnetpp::cMessage) Mysimulation.Switch5.eth[1].queue.scheduler.IntervalTimemsg -- 检查 模块析构函数
实际上这是我通过模拟一遍又一遍地使用两个计时消息创建的模块。上网看了下,发现这个错误与创建的对象在应该删除的时候没有被删除有关。
void PriorityScheduler::initialize() {
gateCycleTimemsg = new cMessage("gateCycleTimemsg");
scheduleAt(baseTime , gateCycleTimemsg);
// baseTime = 2s
}
void PriorityScheduler::handleMessage(cMessage *msg) {
if (msg == gateCycleTimemsg) {
if (currentList == (lastIntervalTime)) {
delete msg;
gateCycleTimemsg = new cMessage("gateCycleTimemsg");
scheduleAt( simTime() + gateCycleTime , gateCycleTimemsg);
...
IntervalTimemsg = new cMessage("IntervalTimemsg");
scheduleAt( simTime() + Interval , IntervalTimemsg);
}
else if (currentList == (firstIntervalTime)) {
gateCycleTimemsg = msg; // same message reused
scheduleAt(simTime() + gateCycleTime , gateCycleTimemsg);
//gateCycleTime = 10 seconds
...
IntervalTimemsg = new cMessage("IntervalTimemsg");
scheduleAt( simTime() + Interval , IntervalTimemsg);
// Interval = 1s
}
}
else if (msg == IntervalTimemsg) {
if (currentList == (lastIntervalTime));
else{
IntervalTimemsg = msg;
scheduleAt( simTime() + Interval , IntervalTimemsg);
}
}
插件路径:/home/amr/omnetpp-5.0/samples/etc/plugins;./plugins 在抛出一个实例后调用终止 'omnetpp::cRuntimeError' what(): 对象 pk-56-145 当前在 (omnetpp::cEventHeap)simulation.scheduled-events,它不能 删除。如果在 omnetpp::cEventHeap 内部发生此错误,则需要 更改为在删除该对象之前调用 drop()。如果这 omnetpp::cEventHeap 的析构函数内部发生错误,而 pk-56-145 是 类成员 omnetpp::cEventHeap 需要在 析构函数
我创建了一个构造函数和析构函数。在网上阅读解决方案后,我还创建了函数 finish()。这仍然没有解决它。
我还删除了收到的每条消息并在发送时创建了一条新消息,但它没有改变任何东西。
编辑:我用删除味精编辑了编码;我添加并给出了时间示例并添加了以下部分,
BaseTime 'BT',gateCycleTime 'CT',间隔 'IT'
----> BT
<---- IT1 ----> <----- IT2 ----> .........<-------- ITx -------->
<------------------------------ CT ----------------------------->
我对 BT 和 CT 使用了相同的消息,而对 IT 使用了另一条消息,因为我不知道最后一个 IT 'ITx' 的时间。
【问题讨论】:
标签: omnet++