Skip to content

Commit

Permalink
Destroy memory leak.
Browse files Browse the repository at this point in the history
  • Loading branch information
lev-k committed Oct 31, 2014
1 parent ce6faa3 commit cbf1db2
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
10 changes: 10 additions & 0 deletions ext/rapngasm/rapngasm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,16 @@ rgba* from_ruby< rgba* > (Object o)
return rgbaArray;
}

template<>
const std::string& from_ruby< const std::string& > (Object o)
{
static std::string tmp;
String str(o);
tmp.clear();
tmp.append(str.c_str());
return tmp;
}

//size_t APNGAsm::wrap_add_frame_rgb(Object pixels, unsigned int width, unsigned int height, Object trns_color = NULL, unsigned delayNum = DEFAULT_FRAME_NUMERATOR, unsigned delayDen = DEFAULT_FRAME_DENOMINATOR) {
// return this.addFrame(from_ruby<rgb*>(pixels), width, height, from_ruby<rgb*>(trns_color), delayNum, delayDen);
//}
Expand Down
16 changes: 15 additions & 1 deletion spec/rapngasm_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,24 @@
#Dir.mkdir('./spec/out') unless Dir.exist?('./spec/out')
#RubyProf.measure_mode = RubyProf::MEMORY
#RubyProf.start
20000.times do
count = 0
loop = 10000
interval = 1000
loop.times do
apngasm_m = APNGAsm.new
apngasm_m.add_frame_file('./spec/support/test1.png', 100, 1000)
apngasm_m.add_frame_file('./spec/support/test2.png', 100, 1000)
apngasm_m.reset
apngasm_m = nil

count += 1
if (count % interval) == 0
# disabled = GC.enable
# GC.start
# GC.disable if disabled

# p "#{count}/#{loop}"
end
end
#result = RubyProf.stop
#printer = RubyProf::FlatPrinter.new(result)
Expand Down

0 comments on commit cbf1db2

Please sign in to comment.