Marc Weber wrote:
Excerpts from Adam Chlipala's message of Wed Dec 01 15:50:26 +0100 2010:
Yes and no.  The global functions will accomplish what you want.
However, pointers allocated by uw_malloc() should not be referenced
across requests.  You should use regular malloc() for such memory.  Note
that uw_set_global() allows you to specify a function to call to free
the value you set; for anything that lasts across requests, you do need
to start thinking about explicit freeing.
What does "request" mean exactly?

The user (browser) issues a request. Then urweb will run code and maybe
retry. Therefore its still the same request.

1) request made
2) urweb runs code, C is calling abort (retry)
3) urweb reruns code - this time there is success.

You can think of pointers being invalidated every time your Ur/Web request handling function is run. So, before/after both 2) and 3).

 From reading "request" in docs I assumed its always freed after 3).
So you should be more explicit. Probably its best to clarify this in the
description of uw_malloc.

I agree.  I'll fix that.

Between 2) and 3) heap may increase. But when will the old heap be
freed? if it was freed after 3) you could use uw_malloc for keeping the
cache data (improving speed)

This could have a big impact on memory usage. You'd essentially need a separate heap for each failed execution whose pointers you want to keep valid. Because of that, and the extra code complexity it would bring, I'm not planning to change it. Using malloc() seems fine to me.

_______________________________________________
Ur mailing list
[email protected]
http://www.impredicative.com/cgi-bin/mailman/listinfo/ur

Reply via email to