Hi everyone, I am trying to write a simple batch Excel extractor: I have an array of file names that I created a .each loop for. In the loop (under Exception handling) I open that file, add the name of the file to another spreadsheet (which I created earlier), then move on to the next file.
This works great for the first 3 files, but after that I get malloc errors and eventually the app crashes with an EXC_BAD_ACCESS error in the Garbage Collection Work Queue. Code: require 'rubygems' require 'write_xlsx' require 'roo' class SimpleExcelExtractor attr_accessor :input_path, :output_path, :input_button, :output_button attr_accessor :quit_button, :go_button, :sheet_text, :column_text, :row_text GUI Stuff ... ... ... def run_func(input, filelist, sheet, column, row, output) row = col = 0 wb = WriteXLSX.new(output) worksheet = wb.add_worksheet p filelist filelist.each do |f| begin input_file = Excelx.new(input + "/" + f) p "Opened file: " + f worksheet.write(row, col, f) p "Wrote it up" row += 1 p "Went ahead" input_file rescue Exception => e p e end end p "Saving now" wb.write p "Saved" end def quit_func(sender) end end Debug output: *["test 2.xlsx", "test.xlsx", "test2 2.xlsx", "test2.xlsx", "test3 2.xlsx", "test3.xlsx", "test4 2.xlsx", "test4.xlsx"]* *"Opened file: test 2.xlsx"* *"Wrote it up"* *"Went ahead"* *"Opened file: test.xlsx"* *"Wrote it up"* *"Went ahead"* *"Opened file: test2 2.xlsx"* *"Wrote it up"* *"Went ahead"* *"Opened file: test2.xlsx"* *SimpleExcelExtractor(57679,0x1082f6000) malloc: *** free() called on collectable block with 0x401234b20 with refcount 0 (ignored)* *"Wrote it up"* *"Went ahead"* *SimpleExcelExtractor(57679,0x1082f6000) malloc: *** free() called on collectable block with 0x4016622e0 with refcount 0 (ignored)* *SimpleExcelExtractor(57679,0x1082f6000) malloc: *** free() called on collectable block with 0x40127b640 with refcount 0 (ignored)* *SimpleExcelExtractor(57679,0x1082f6000) malloc: *** free() called on collectable block with 0x40138b7a0 with refcount 0 (ignored)* *SimpleExcelExtractor(57679,0x1082f6000) malloc: *** free() called on collectable block with 0x40154cd40 with refcount 0 (ignored)* *SimpleExcelExtractor(57679,0x1082f6000) malloc: *** free() called on collectable block with 0x40136d4c0 with refcount 0 (ignored)* *SimpleExcelExtractor(57679,0x1082f6000) malloc: *** free() called on collectable block with 0x4016d2620 with refcount 0 (ignored)* *(lldb) * Then in the Debug window it has the following in the Garbage Collector Work Queue: #include <xml_node_set.h> #include <libxml/xpathInternals.h> static ID decorate ; static int dealloc_namespace(xmlNsPtr ns) { if (ns->href) <----Thread 12: EXC_BAD_ACCESS (code=1, address = 0x22) xmlFree((xmlChar *)ns->href); if (ns->prefix) xmlFree((xmlChar *)ns->prefix); xmlFree(ns); return ST_CONTINUE; } -- F. Timur Senguen, Ph.D. VP of Testing and Science Reviewed.com - A division of USAToday 411A Highland Ave Somerville, MA 02155 USA reviewed.com
_______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo/macruby-devel