Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Reply
Regular Contributor
Posts: 65
Registered: ‎01-21-2011
My Device: Not Specified

net.rim.device.api.database.DatabaseOutOfMemoryException: commit: out of memory in HTML5_INIT.js

I'm using the HTML5_init.js on to have code that works on OS5 and OS6 and i've just introduced an interval to my application which checks to see if there is any data to be processed. After the app had run for a while it was experiencing a DatabaseOutOfMemoryException. I've pealed back everything form my application and found that when i just select from a table over and over again eventually i get an out of memory exception being thrown. Since it's using HTML5_init.js it is calling the close() method on the gears database so it shouldn't be that old chesnut..

 

Here is the very simple code to reproduce, can anyone tell me what i could be doing wrong:

 

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
<html>
	<head>
	    <meta name="viewport" id="viewport" content="height=device-height,width=device-width,user-scalable=no" />
		<title>Untitled Page</title>
		<script langauge="javascript" type="text/javascript" src="/html5_init.js" id="html5_init"></script>
	    <script langauge="javascript" type="text/javascript" src="/html5_worker.js"></script>
        <script language="javascript" type="text/javascript">
            var db;
            var doSelectCount = 0;
            var databaseName = "MemoryLeakTest";
            var databaseDescription = "MemoryLeakTest";
            var databaseSize = 1024 * 1024;
            var selectIntervalId;
            
            function onLoad() {
                databaseSetup();
            }

            function databaseSetup() {
                db = window.openDatabase(databaseName, "", databaseDescription, databaseSize);
                db.transaction(function(tx) {
                    //check to see if config table exists. if it doesn't exist then create the db tables.
                    tx.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name=?", ["testTable"], function(tx, resultSet) {
                        if (resultSet.rows.length == 0) {
                            tx.executeSql('CREATE TABLE IF NOT EXISTS testTable(oid INTEGER PRIMARY KEY ASC AUTOINCREMENT, test TEXT)', [], function(tx, rs) {
                                //Table created;
                                selectIntervalId = setInterval(doSelect, 100);
                            }, function(tx, err) {
                                alert("Error executing create statement");
                            });
                        }
                        else {
                            //table already exists
                            setInterval(doSelect, 100);
                        }
                    }, function(tx, err) {
                        alert("There was an error createing the test table");
                    });
                });
            }

            function doSelect() {
                db.transaction(function(tx) {
                    tx.executeSql("SELECT * FROM testTable", [], function(tx, rs) {
                        doSelectCount++;
                        document.getElementById("selectCount").innerHTML = doSelectCount;
                    }, function(tx, err) {
                        clearInterval(selectIntervalId);
                        alert("An error occured executing select statement");
                    });
                });
            }
            
            
        </script>
	</head>
	<body onload="javascript&colon;onLoad();">
        <div>Do select has been run: <span id="selectCount"></span> times</div>
	</body>
</html>

Regular Contributor
Posts: 65
Registered: ‎01-21-2011
My Device: Not Specified

Re: net.rim.device.api.database.DatabaseOutOfMemoryException: commit: out of memory in HTML5_INIT.js

The error occurs for me on the OS5 (5.0.0.517) simulator after about 174 selects each time... 

 

I've just replaced the HTML5 style implementation with direct gears executes and it's got upto 30,000 + selects no problem

Highlighted
Regular Contributor
Posts: 65
Registered: ‎01-21-2011
My Device: Not Specified

Re: net.rim.device.api.database.DatabaseOutOfMemoryException: commit: out of memory in HTML5_INIT.js

Got hold of a real OS5 device and it appears to work ok on the real thing or at least OS 5.0.0.1015 Smiley Frustrated