Console log / dump memory errors


I have a bunch of console.log/console.dumps in my app. Could not commenting those out lead to memory errors when the app is deployed to a phone?

I have a phone that has been getting memory errors and it got me wondering if the console messages could be the issue.

I need to troubleshoot more to get to the bottom of the issue, but I wanted to ask and see what others have experienced with leaving the console messages in the app.



The console.log themselves will NOT cause any memory issues; however any code running from routines your call inside the console.log might.

Take this example

console.log("Value:", checkSomeWork());
function checkSomeWork() {
  workElement = getElementById('Work');
  return workElement .value;

You just leaked a workElement reference into the global scope from the first line of and so it and all its parents will not be cleaned up. So you have a memory leak because you ended up with a side-effect in a routine that you were using to get the value that you were printing.

But if you are doing a simple:
console.log("Hi this is a test", value1, value2, value3); this wouldn’t leak anything because it is converted to a string and wrote out the the android logger system.

Nathanael A.


That makes sense. Thank you.