How do I wipe the memory to avoid overloading?

Asked

Viewed 253 times

-3

As you read the HTML of the site, go deleting what is before. If there is any clear screen in Python.

import mechanize

response = mechanize.urlopen("https://www.exemplo.com")
m = 0
linha = ''
if (m < 100):
  for n in response.read():
    m += 1
    linha += n
    if (n == '\n'):
      print(linha)
      linha = ''
  • answer solved your question? Do you think you can accept it? See [tour] if you don’t know how to do it. This would help a lot to indicate that the solution was useful for you. You can also vote on any question or answer you find useful on the entire site (when you have 15 points).

1 answer

1

Python is a language that manages your memory automatically so you don’t have to do anything, memory is released when it’s no longer needed. In such a case consumption is small.

Anyway if it is running on a web server even if it was not automatic or would make a difference because of the fleeting feature of scripts web.

And it would make no sense to clean the screen to free the memory, one thing has nothing to do with another.

  • I used this code, but without the if limiter. I left it straight this way print(Response.read()) and just stuck .. every time (what happened then? ) ex: import mechanize Response = mechanize.urlopen('www.site.com') print(Response.read())

  • Hard to know just with this information. That doesn’t seem like much and that’s causing the problem.

  • I used to read youtube html and it worked, but the other site as it had a very large html, hangs. I think it’s memory read=mechanize.urlopen"https://www.youtube.com/") print(read.read())

Browser other questions tagged

You are not signed in. Login or sign up in order to post.