S
S
spectator1002018-12-07 15:28:19
Browsers
spectator100, 2018-12-07 15:28:19

Why is my Chrome extension consuming so much RAM?

Hello! I have a homemade extension that adds sound notifications to one browser game.
The script is very simple, but with each click, the amount of RAM usage increases. I tried everything, but unfortunately I can't solve the problem.
Here is the extension code itself:
content.js file

var audio = new Audio(); 
  audio.src = chrome.extension.getURL("sounds/warn.ogg");
    var audio_paraliz = new Audio(); 
  audio_paraliz.src = chrome.extension.getURL("sounds/paraliz.mp3");
  
$(document).ready(function() {
    if (window.top.bgrdown == undefined) {
        return;
    }
     spl_link = $(window.top.bgrdown.document.getElementById("sp0"));
    if (spl_link) {
         links_spl = spl_link.find('a');
        links_spl.each(function(){
             CurLinkSpl = $(this);
       matches_P = CurLinkSpl.text().match(/Парализ/);
            if (matches_P) {
                audio_paraliz.play();
            }

      
      
      
      });
    }

  
  
     aElem = $('#a1');
    if (aElem) {
         links = aElem.find('a');
        links.each(function(){
             currentLink = $(this);
             matches = currentLink.text().match(/.*(\d+)/g);
            if (matches) {
                audio.play();

            }
        });
    }

  delete spl_link;
delete links_spl;
delete CurLinkSpl;
delete matches_P;
delete aElem;
delete links;
delete currentLink;
delete matches;

  });

Manifest file:
{
  "manifest_version": 2,
"content_security_policy": "script-src 'self' https://*.bbgam.com/*; object-src 'self'",
  "web_accessible_resources": [
    "*.ogg", "*.mp3", "*.wav"
  ],
  "name": "Skazanie",
   "description": "Добавляет звуковое сопровождение в игре Skazanie",
  "version": "2.0.2",
  
  "icons": {
    "128": "icon_128.png"
  },
  "content_scripts": [
    {

  "matches": [ "http://*.bbgam.com/*" ],
      "all_frames": true,
            "js":["js/jquery.min.js", "js/content.js"]
    }
  ],
  "permissions": [
        "http://*.bbgam.com/*",
 "\u003Call_urls>"
    ],

      "browser_action": {
        "default_title": "FinderSkazanie",
        "default_icon": "icon.png",
        "default_popup": "popup.html"
    }
  
}

there is nothing in popup.html.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stalker_RED, 2018-12-14
@Stalker_RED

You can open the background page extension in the inspector
and use the profiler to see what's happening with the memory.
https://developers.google.com/web/tools/chrome-dev...
There are articles on developers.google.com and videos on YouTube about this tool. It's hard to say anything more.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question