[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Best way to save/re-load an lua state
- From: Ben Sunshine-Hill <sneftel@...>
- Date: Fri, 20 Mar 2009 12:40:31 -0400
I wouldn't suggest #2. There's a lot of types of objects referenced by
the lua_State, with some moderately complicated connectivity. It's
certainly possible, but it's a pain in the tuckus.
If you want to serialize *everything* in the Lua state, the easiest
approach is a Lua variant called lper. That basically does your #3.
It's unix-specific, though... I'm not sure how much work would be
involved in porting it to win32.
On Fri, Mar 20, 2009 at 7:10 AM, email@example.com <firstname.lastname@example.org> wrote:
> I want to save the state of a Lua VM to a file to re-load and restart
> execution later.
> Three options come to my mind:
> 1. Serializing the global index table of the VM. I even found a library
> called "Pluto" which promises to do this.
> 2. Trying to make a deep copy of the lua_State* pointing to a VM and
> save/load the binary data.
> 3. Trying to overwrite malloc/free for the Lua.dll, place all memory the VM
> holds in an pre-allocated chunk. Save and re-load that whole chunk. I'm not
> sure If I'm yet experienced (in C/C++) enough to get this done. Probably
> My Questions are:
> 1. Which of that options will work or which one are used and which not?
> 2. Are there any other options I missed?
> 3. Which option is most promising in terms of time and complexity?
> 4. Are there any other helper libraries (beside Pluto) which helps doing one
> of the options?
> Thank you!