Take the 2-minute tour ×

I have a Google map running with scripts (jQuery) and consuming markers and polygons from a bunch of RESTful web services deployed in the same server. All seems to work fine, but after a few minutes of running a simulation (simply redrawing the overlays after n seconds with the setInterval function) my computer shuts down! I am not even getting the Blue Screen of Death (BSoD), the computer just goes off!

I realised it has something to do with memory (removing other overlays code, takes longer to go off). I think I did release memory as you can see in this snippet, but I am not certain. What am I missing?

function deleteOverlay(overl) {
    if (overl)
        for (i in overl)
        overl.length = 0;
        overl = [];

function populate(map) {
    var infowindow = new google.maps.InfoWindow({content: ''});
    jQuery.get("/MyServiceRESTful/resources/passengers/", {}, function (data) {
        jQuery(data).find("passenger").each(function () {
            var marker = jQuery(this);
            var idtxt = marker.attr("id");
            var sntxt = marker.attr("snippet");
            var location = marker.attr("lat")+', '+marker.attr("lng");
            var latlng = new google.maps.LatLng(parseFloat(marker.attr("lat")),parseFloat(marker.attr("lng")));
            var marker = new google.maps.Marker({
                            position : latlng,
                            map : map,
                            title : marker.attr("id") + " [" + marker.attr("snippet") + "]",
                            animation : google.maps.Animation.NONE,
                            icon : passengermarker
            var contentString = 'Hi';
            google.maps.event.addListener(marker, 'mouseover', function () {
                infowindow.content = contentString;
                infowindow.open(map, marker);

    //More similar calls
share|improve this question
i dnt think its a browser side issue.. your browser wont cause a system crash.. looks like an issue with your server processing these requests.. may be you are sending in abnormally large no of requests.. watch the Network tab in dev tools for the no of requests fired –  Baz1nga Aug 25 '11 at 10:58
Thanks for replying. You might be right after checking the server log it shows requests from the same service each 6ms. I am only requesting for 4 services every second (from the script) which is something a server certainly can handle. Not sure how to control this No. of requests better, something related to how gmaps or jQuery get request perhaps? –  cevel Aug 25 '11 at 11:39

1 Answer 1

up vote 0 down vote accepted

After the discussion in the chat above and looking at your code, it looks like you are making no of calls to your web server and this is causing your server to meltdown.

I would suggest you make these calls to the server dynamic, that is, make it on request instead of loading it up front for whatever reason.. If, as a single person, you are ending up killing your server, I can't imagine what will happen when your site goes live.. Ideally make it as on demand as possible attach events to your map objects and fire them only when necessary.

I hope this is a valid approach you could take or please update the question to show us more code and what you are trying to achieve..

share|improve this answer
It seems I need to get back to the drawing board. You are right about the actual problem being in the web service and the way is handling requests. Need to probably cache some results or limit the No. of requests per second. If anything, will post a new question. –  cevel Aug 29 '11 at 4:43

Your Answer


