| Page 1 of 1 | [ 3 posts ] |
|
Hi there,
I've been trying to track down a memory leak and narrowed it to where we are using DataSource.IO. I'm not sure how we are supposed to do setTimeout calls and that is possibly the cause of the leak. I also tried DataSource.Get using the same setTimeout approach and didn't find any problems. Finally, I commented out the log statements and still saw the memory use climb. As for the size of the leak, it took about 4 hours to reach approximately 1.0 GB on each of Safari 5.0.5 and Firefox 5.0 on a Mac, with a 1 second delay between calls. The data that I returned was a flat file response copied from the example page. Please let me know if I should do other testing, or provide hints/workarounds. Thx, -rob Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <link rel="shortcut icon" type="image/x-icon" href="http://www.viaas.com/service/media/favicon.ico" /> <title>Memory leak test 5</title> </head> <body> <script src="http://yui.yahooapis.com/3.3.0/build/yui/yui-min.js" charset="utf-8"></script> <script type="text/javascript" charset="utf-8"> var globalY; function fetch(Y) { var myDataSourceJSON = new Y.DataSource.IO({source:"memleak5.json?"}), myCallbackJSON = { success: function(e){ Y.log(e); setTimeout("fetch(globalY)", 1000); }, failure: function(e){ Y.log(e); } }; myDataSourceJSON.plug(Y.Plugin.DataSourceJSONSchema, { schema: { resultListLocator: "ResultSet.Result", resultFields: ["Title"] } }); myDataSourceJSON.sendRequest({ request:"output=json", callback:myCallbackJSON }); } YUI({filter: 'raw'}).use('datasource', 'json', function(Y){ globalY = Y; fetch(globalY); }); </script> </body> </html> |
Juan Ignacio DopazoYUI Contributor
|
Well... DataSources are designed in order to create once instance per source instead of one instance per request. Your problem is clearly in that your datasource instances aren't being cleared because you're not calling any instruction that triggers garbage collection. And that's ok, you shouldn't.
I definitely recommend you to write just one datasource instance and use the Pollable extension: Code: YUI().use('datasource-io', 'datasource-polling', function (Y) { var myDataSourceJSON = new Y.DataSource.IO({ source: 'memleak5.json?', on: { data: function (e) { Y.log(e); }, error: function (e) { Y.log(e); } } }), interval = myDataSourceJSON.setInterval(1000); }); |
|
Thanks Juan, that made sense to try. Unfortunately, while it may have reduced the speed of the leak a little (I didn't test for 4 hours so I'm not sure), there is still a leak even using the polling approach (and a single instance of DataSource.IO).
I ran the new code for about 30 minutes and memory increased from 70MB to 222MB in FF, and 26MB to 82MB in Safari. Both were run with the log statements commented out, in case that was a possible leak. Any other ideas? |
| Page 1 of 1 | [ 3 posts ] |
| You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum |
© 2006-2013 Yahoo! Inc. All rights reserved.
All code on this site is licensed under the BSD License unless stated otherwise.
About This Site · Security Contact Info
Powered by phpBB® Forum Software © phpBB Group