dump with Tk ... anyone?

From: Harvey J. Stein <hjstein_at_math.huji.ac.il>
Date: Wed, 14 Dec 1994 20:41:39 +0200

Loy D'Souza writes:
>
> Hi!
> I know that dump is not supposed to be currently working with Tk
> initialized. But does any one have a work around for this ?. Can
> Eric tell us if he is thinking of supporting this in v2.2 ?

Since I've been guessing so much lately, I'll venture another guess
:). Dumping currently is similar to generating a core dump. The
actual memory state is written out to a file. If only scheme is
running, then this works fine, since scheme only has a current state.
However, if Tk is initialized, then one can also have all these
objects in memory which, if they're re-created, need various sorts of
initializations to be done before they're valid objects. Not only
that, but the initializations must be done in the proper order, and it
is probably the case that there is insufficient information in memory
to reconstruct the needed initializations.

For example, if I do:

(frame '.f ...)
(button '.f.b ...)
(pack .f)
(pack .f.b)

or something along these lines, & then tries to dump memory, the
problem becomes that the frame & button created are not merely scheme
objects residing in memory, but have widgets associated with them
created through Tk calls. Even dumping both won't work, because to
instantiate a button, for example, Tk has to make a bunch of X calls.
You couldn't just re-do all the Tk calls, because you can still have
all these scheme objects sitting around referencing the memory
associated with these non-functional widgets, so you'd have to go
through memory re-wiring it to point to the new widgets. This is
assuming that you could piece together exactly how to recreate all the
widgets.

So, I'd expect that it'd be pretty difficult to dump memory if Tk has
been used. Since just running STk (without the -no-tk switch) causes
various initialisations to the Tk part of STk, even just starting it
without the -no-tk switch & trying to dump memory could be problematic
(for example, there's the *root* variable which would have to be
re-initialized to point to the new top-level window).

The work-around I've been using is to package up all my code so that
it can be loaded without invoking any Tk functions. I define a
function called build-me which does all the widget creation. Then, I
can load the code into STk and do a dump. This dump can then be
loaded in with the -init switch & the widgets can all be built just by
executing (build-me). To seal everything up into a simple package, I
can make an auxiliary STk script just containing the (build-me)
command, and a shellscript which runs STk passing the image dump with
the -image switch & this auxiliary script with the -file switch.

The only problem is that the above didn't work for me with the -load
switch instead of the -file switch - a minor inconvenience.

Good luck,

Dr. Harvey J. Stein
Berger Financial Research
hjstein_at_math.huji.ac.il
Received on Wed Dec 14 1994 - 19:43:51 CET

This archive was generated by hypermail 2.3.0 : Mon Jul 21 2014 - 19:38:59 CEST