angularjs e2e test with $http and out of memory exception

My experience with $httpBackend with e2e tests and out of memory exceptions.

$httpBackend and out of memory exceptions

I am running yadda with casperjs to do functional end to end testing.

I was doing a simple $http request that would expect some JSON back.  I was getting through 2.5gb of ram before my Casperjs test would fall over with out of memory exception and Phantomjs telling me how to report this bug.  I followed the instructions to get an error report for Phantomjs and it was not giving me any useful information for a bug report, so it was something in my code that was the problem.

What I figured out:

Returning invalid JSON and making lots calls to the $httpBackend in quick succession then I experienced my tests falling over very quickly with out of memory exceptions.  It also slows down the tests as the memory does not get released very quickly.

If you make lots of calls to $httpBackend full stop then it tends to chew through lots of memory.  Use it sparingly and have your code against calling it too frequently as it is very expensive.

There is caching available for on $http requests but I have not used it yet. $http


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s