[Devel] Memory woes

Bastian Friedrich bastian.friedrich at collax.com
Tue Jan 30 20:07:45 CET 2007


Hi,

On Tuesday 30 January 2007 19:25, Daniel-Constantin Mierla wrote:
> how do you do the fixup for exported functions? At statup, or every time
> you call a function from Perl? In the second case, it is tough, because
> after a fixup, the new parameter value can be a structure or something
> else, and it is not easy to free. The best is to do it once, at startup
> or at first execution, and then reuse it, if possible.

Houston, we've got a problem. :(

Unfortunately, a perl script can - and commonly will - never use the same set 
of parameters twice for a call to the same function. Imagine something like 
this:
====================


sub foo {
  my $msg = shift;

  my $ruri = $msg->getRURI();

  $msg->xlog(..., "I'm processing a call to $ruri");

  return 1;
}
====================

This means that everytime xlog is called, the fixup for
"... $ruri" has to be found - and $ruri is not even remotely static. Doing the 
fixup only once is thus not possible.


I'd like to propose the following concept:

- Add a "cleanup" function pointer to action_elem_t
- Let every (!) fixup function in all modules set a pointer to a function that
  does the cleanup.
  * This could be NULL, e.g. where the fixup'd data is an integer
    (e.g. sl_send_reply)
  * A pointer to pkg_free(), where fixup'd data is a string
  * A pointer to a newly written function that cleans up structures for more
    hierarchic data structures
- the perl module could then call this "cleanup" function after processing.


Yes. I know. It's not nice, but the whole concept of fixup functions is in the 
way in the context of the perl module.

Sorry for the mess; my patch from today probably (no, definitely!) does _not_ 
do things right. Unfortunately, there's a conceptual problem that is not 
easily solvable at this point.

I hope you understood my concerns. Maybe you can come up with a better 
solution :)

Best regards,
   Bastian

-- 
Collax GmbH . Burkheimer Straße 3 . 79111 Freiburg . Germany
p: +49 (0) 761-45684-24
f: +49 (0) 761-45684-10        www.collax.com

+++Besuchen Sie uns auf der Cebit vom 15.3. bis 21.3 2007 in Hannover
+++Halle 5 Stand F63
\ 1st Law of Thermodynamics: Go to class!!



More information about the Devel mailing list