A
A
Anton Danilkin2017-04-21 04:05:24
JavaScript
Anton Danilkin, 2017-04-21 04:05:24

How to fix a memory leak when using the Vkontakte widget?

There is a site where content is loaded using ajax and history api.
The pages have VKontakte Wall Post widgets that are initialized as follows:

(function () {
      if (!window.VK || !VK.Widgets || !VK.Widgets.Post || !VK.Widgets.Post("vk_post_-1111_111", - 1111 , 111 , 'hash',{redesign: 1}))setTimeout(arguments.callee, 50);
    }());

<div id="vk_post_-1111_111"></div>
When deleting a widget, for example: The memory is not freed and clogged. And over time, with a large number of loaded widgets, an error occurs in the browser, which reports a lack of memory. How can this problem be solved?
$('#vk_post_-1111_111').remove();

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
dummyman, 2017-04-21
@dummyman

A friend about a year and a half ago was banging his head against the wall with this question.
The solution was simple - run the code inside the iframe, destroying the iframe, the memory is freed.

M
Maxim Solovyov, 2017-04-21
@maxsolovev

Have you tried just clearing window from VK? window is not cleaned up by the garbage collector.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question