Where do I fix: undisposed object --check module destructor?

443 views
Skip to first unread message

alanxptm

unread,
Jun 23, 2022, 4:26:17 PM6/23/22
to OMNeT++ Users
I have finally finished my project, but every time I end the simulation I get messages about this in the console:

undisposed object: (InternalMessage) Net.intG[1].intPeer. -- check module destructor

I guess that it must be because I keep messages in several buffers, which is part of the simulation, but I ignore if leaving them like that its a problem for my system once the simulation has been finished and Omnet closed, or a warning just in case. The docs info says:
  • Destructor:

    Delete everything which was allocated by new and is still held by the module class. With self-messages (timers), use the cancelAndDelete(msg) function! It is almost always wrong to just delete a self-message from the destructor, because it might be in the scheduled events list. The cancelAndDelete(msg) function checks for that first, and cancels the message before deletion if necessary.

OMNeT++ prints the list of unreleased objects at the end of the simulation. When a simulation model dumps "undisposed object ..." messages, this indicates that the corresponding module destructors should be fixed. As a temporary measure, these messages may be hidden by setting print-undisposed=false in the configuration.

My questions are.. Where the module destructor is or do I need to implement it? How do I implement that? and How do I know which objects do I need to dispose?

alanxptm

unread,
Jun 23, 2022, 10:40:21 PM6/23/22
to OMNeT++ Users
I've created the finish method with a buffer cleaner but now I get an error exit when I terminate the simulation as if it just crashed

void Peer::finish(){
    if(!buffer.empty()){
        for(int b = 0; b < buffer.size() || buffer.empty(); ++b){
            delete(get<0>(buffer[b]));
            buffer.erase(buffer.begin() + b);
            b--;
        }
    }
}


Alfonso Ariza Quintana

unread,
Jun 24, 2022, 3:35:01 AM6/24/22
to omn...@googlegroups.com
Is it possible that you have a message that you use for creating a timer?

De: omn...@googlegroups.com <omn...@googlegroups.com> en nombre de alanxptm <alan...@gmail.com>
Enviado: viernes, 24 de junio de 2022 4:40
Para: OMNeT++ Users <omn...@googlegroups.com>
Asunto: [Omnetpp-l] Re: Where do I fix: undisposed object --check module destructor?
 
--
You received this message because you are subscribed to the Google Groups "OMNeT++ Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to omnetpp+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/omnetpp/2c264b6b-b585-4290-947c-419836899db1n%40googlegroups.com.

alanxptm

unread,
Jun 25, 2022, 7:47:35 PM6/25/22
to OMNeT++ Users
No, but I've found that it's becuase I was creating msgs and not deleting them after being sent. Thank you, I've created an event now and took care of that.
Reply all
Reply to author
Forward
0 new messages