Re: how to cleanly unregister a scalar (w/o memory leaks and such)?

"Dave Shield" <[email protected]>
Newsgroups gmane.network.net-snmp.user
Message-ID <[email protected]>
On 23/07/07, Dirk Süsserott <[email protected]> wrote:
> So I called
> ------------- 8< -----------------------------------------------
> free( my_scalar );
> netsnmp_unregister_handler( reg );
> ------------- 8< -----------------------------------------------
>
> Works fine, the variable is no loger reported by snmpwalk.
> But don't I have to de-allocate the watcher-info?

In principle, that should probably be handled by the
'netsnmp_unregister_handler()' call.

In practice, the Net-SNMP agent is not particularly good about
releasing memory during "shutdown-time" activity.  So in fact,
both the watcher structure *and* the main registration structure
seem to be left allocated.

The correct behaviour is probably something we need to discuss
properly, but I'm inclined to say that the unregister call should
take care of both of these.
   In any case, we need to ensure that the intended behaviour
is clearly documented.


>                          And/or somehow
> have to "undo" the call to netsnmp_register_watched_scalar()?

No - that *is* handled by the 'netsnmp_unregister_scalar' call.


> Do I have to call SNMP_FREE(reg) or SNMP_FREE(winfo)
> or does that already take place behind the scenes?

At the moment, yes you need to call (both of) these yourself.
It may turn out that this memory management is included within
the unregistration call in future - but this will be documented
if we decide to go down that path.

Dave

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Net-snmp-users mailing list
[email protected]
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.