
Memory Leak in MySql Query
Reported by James | July 6th, 2008 @ 09:43 AM
MySQL queries leak about 3M every 10000 documents. I'm thinking the amount leaked depends on the size of the document record.
The following script run with merb -r exposes the leak:
pid = Process.pid
line_count = 0; found_count = 0
ARGF.each do |line|
if line_count % 10000 == 0
ps = `ps -eo pid,rss,vsz`.grep(/^#{pid}/)[0].chomp
puts "#{ps} #{line_count} #{found_count}"
end
checksum = Digest::MD5.hexdigest(line)
found_count += Document.get(checksum) ? 1 : 0
line_count += 1
end
Here's some example output:
PID RMEM VMEM lines found
16888 29604 94292 0 0
16888 40800 105164 10000 10000
16888 43564 107924 20000 20000
16888 46348 110836 30000 30000
16888 49128 113652 40000 40000
16888 51856 116312 50000 50000
16888 54832 119316 60000 60000
...
16888 467800 533548 1130000 1130000
16888 470880 536596 1140000 1140000
16888 474068 539644 1150000 1150000
16888 477180 542696 1160000 1160000
16888 480468 545852 1170000 1170000
16888 483600 549004 1180000 1180000
16888 486848 552156 1190000 1190000
16888 490036 555196 1200000 1200000
And another run where not all the records are in the database:
24431 118720 183268 1440000 160922
24431 121748 186216 1450000 162522
24431 125296 190688 1460000 164114
24431 128136 193448 1470000 165656
24431 131040 196192 1480000 167310
24431 134008 199136 1490000 168861
24431 137016 202056 1500000 170490
24431 140004 204984 1510000 171951
24431 143088 208004 1520000 173621
24431 145968 210824 1530000 175237
24431 148964 213748 1540000 176819
I'm using DataMapper 0.9.3 edge!
Patch for bug #270 IS installed.
Please help!
Thanks.
JamesO
Comments and changes to this ticket
-
Serhiy Boiko July 14th, 2008 @ 02:48 AM
I have also discovered this issue. When you trying to select about 3000 records from usual table, it leaks.
-
Serhiy Boiko July 15th, 2008 @ 10:26 AM
I have written test script, that create big array of hashes and have observed memory leak.
So, it is possible that Ruby leaks on big array of data.
Test script: http://pastie.org/233856
run as: ruby name_script.rb num_of_rows
-
James July 15th, 2008 @ 01:20 PM
Unfortunately, when I convert to ActiveRecord in the same script, I
have no problem. I believe it is definitely a DataMapper problem.
JamesO
On Jul 15, 2008, at 9:26, Lighthouse wrote:
-
Bernerd Schaefer July 20th, 2008 @ 01:36 PM
- State changed from new to resolved
Could you try running this script for me on edge dm? I'm running latest everything, and I'm not getting any big leak (pretty standard progression of memory).
Here's the script:
http://pastie.org/private/gyvabe...
And here are the results:
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
People watching this ticket
- Nobody is watching this ticket.