From: Jamey Cribbs Date: 2006-12-09T04:05:20+09:00 Subject: Re: Marshal::dump error on PowerBook G4 Emmett Shear wrote: > I've written code for a Splay tree in Ruby, and I'm trying to > serialize it using Marshal::dump. > > If I create a tree with 1,000 or 10,000 nodes, Marshal::dump works > perfectly. When I get up to 100,000 nodes, Marshal::dump causes the > irb process to die with the error "Illegal Instruction". > > Is this a known problem? I tried searching for "Marshal::dump" and > "Illegal Instruction" it but I didn't turn up anything. I'm on a > PowerBook G4, running Ruby version 1.8.5 and IRb version 0.9.5. I've > attached the code for the Splay tree; to reproduce, open irb and run: > > require 'splay' > t = SplayTree.new > 100000.times {|i| t[i] = i} > Marshal::dump t I remember running into something similar when I started working on Mongoose, which is a ruby rdbms that uses SkipLists for it's indexing. If I tried to serialize the entire SkipList and it had too many keys, I would get an error. I ended adding a method that converts the SkipList to a hash, then feeds the hash to Marshal.dump, and it worked. I also have another method that loads the Marshalled hash and turns it back into a SkipList. Another thing you could do would be to serialize each SplayNode, instead of the whole tree. HTH, Jamey Cribbs Confidentiality Notice: This email message, including any attachments, is for the sole use of the intended recipient(s) and may contain confidential and/or privileged information. If you are not the intended recipient(s), you are hereby notified that any dissemination, unauthorized review, use, disclosure or distribution of this email and any materials contained in any attachments is prohibited. If you receive this message in error, or are not the intended recipient(s), please immediately notify the sender by email and destroy all copies of the original message, including attachments.