flat assembler
Message board for the users of flat assembler.

Index > Heap > On memory management (specifically GCs)

Author
Thread Post new topic Reply to topic
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17271
Location: In your JS exploiting you and your system
revolution
I have been monitoring the memory usage by Firefox. Basically: it is terrible.

I have not looked at the source code, but I am going to take chance and guess that it uses something known as the "garbage collector". Amirite? If FF doesn't use a GC then no matter the following still applies to any program that uses one.

I'm sure you have all heard of these GC things before. Supposedly they collect up old bits of memory and recycle it for use again later. But when do they run? Therein lies the problem. Many newer languages allow the programmer to be lazy and freely allocate new bits of memory (objects). And often the language does not even have the facility for the programmer to free it later, even if they wanted to, they can't.

Anyhow, so this GC paradigm fails to free all memory reliably. For many short running programs this may not matter, the OS will free all memory when the program closes. But consider what happens for a long running program. Memory leaks. Excessive memory usage for no reason.

FF suffers from this problem. After a few days of running and browsing around the Internet (as we all do) the memory usage gradually expands from ~50MB at start-up to over 300MB. With all tabs closed and sitting idle that 300MB of memory is now forgotten (but allocated) and cannot (or won't, or something) be freed by the GC. The only reason I never see more than 300MB used is because I run out of RAM for FF and are forced to close it and restart to get back to the 50MB usage and start the whole process again.

FF: Y U use GC? Or more appropriately: Y ur GC so sucky? Computers don't have infinite RAM. You are not allowed to simply keep allocating memory. Be responsible and free your memory after use, don't litter, be a good program.
Post 22 Apr 2011, 14:18
View user's profile Send private message Visit poster's website Reply with quote
neville



Joined: 13 Jul 2008
Posts: 507
Location: New Zealand
neville
Very interesting.
I use FF and I can confirm your findings. But IE doesn't seem to be much better, and is generally slower anyway so I stick with FF. Have you done any comparative tests with IE's memory usage?

For the most sensible memory management, get a Memory Operating System! Wink

_________________
FAMOS - the first memory operating system
Post 22 Apr 2011, 21:48
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17271
Location: In your JS exploiting you and your system
revolution
I don't use IE. But my post is not about comparison between programs, it is about the GC paradigm. And in case I didn't make it clear above: relying on GCs to free unused memory is a bad thing.

As for memory OSes, hmm, well, any OS that doesn't use paging is doomed to have memory address fragmentation issues with anything more complex than a single task.
Post 23 Apr 2011, 00:42
View user's profile Send private message Visit poster's website Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 2913
Location: [RSP+8*5]
bitRAKE
Using the dev version of Chrome - if a tab gets out of control then I'll close it and open a new one. I've got maybe 40 tabs open - most of them are less than 2MB in size. Very Happy
Post 23 Apr 2011, 00:49
View user's profile Send private message Visit poster's website Reply with quote
typedef



Joined: 25 Jul 2010
Posts: 2913
Location: 0x77760000
typedef
Chrome is faster and uses less memory than FF and IE...
Chrome is also good for hacking websites...O_o
Post 23 Apr 2011, 01:31
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17271
Location: In your JS exploiting you and your system
revolution
Let's not turn this into a browser war. Just discuss the GCs and memory deallocation strategies.
Post 23 Apr 2011, 01:47
View user's profile Send private message Visit poster's website Reply with quote
typedef



Joined: 25 Jul 2010
Posts: 2913
Location: 0x77760000
typedef
I used to browse with Flock, but it seems like competition was tough...


http://www.flock.com/
Post 23 Apr 2011, 01:53
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
1. I am very skeptical about your claim that GC as a paradigm fails to free up memory reliably. It just doesn't do this deterministically, at known time. One of main reasons for GC is to make programmer-caused leaks impossible, in order to to mass-breed programmer instances faster.

2. I don't think FF uses GC.

3. And I would guess reason for eating up all your RAM is because of some stupid caching, not memory leaking (it's a feature!!!). Did you try things like this and this? Google for more.
Post 23 Apr 2011, 07:23
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17271
Location: In your JS exploiting you and your system
revolution
1. GCs do not always properly detect unreferenced objects, and sometimes the programmer has no way to force an object free.

Some languages wholly rely upon a GC to clear things up and completely remove any freeing statements. That might be great if GCs were perfect and if the GC can be triggered externally when another process needs some RAM to work with. IMO when you no longer need ram you should free it immediately. In a multitasking system if program A is hogging RAM then program B can't run.

[offtopic]
2. Okay, if you are correct then it is just buggy then. But are you sure of this?

3. Been there; done that. I've set all those things a long time ago.
[/offtopic]
Post 23 Apr 2011, 07:50
View user's profile Send private message Visit poster's website Reply with quote
Fanael



Joined: 03 Jul 2009
Posts: 168
Fanael
revolution wrote:
GCs do not always properly detect unreferenced objects
These are called conservative garbage collectors, because they conservatively assume that any value can be a pointer, therefore, they can mistake an integer for a pointer and think that an object is reachable even though it's not. On the other hand, most GCs found in things like JVMs, .NET, etc. are precise: they know whether something is a pointer or not, thus they won't get fooled by an integer that just happened to have a valid value for a pointer, thus they always properly detect unreachable objects. If they don't, chances are they're buggy. And then, the fact they don't detect all unreachable objects is probably your smallest problem.

And... FF doesn't use a garbage collector.
Post 23 Apr 2011, 09:23
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17271
Location: In your JS exploiting you and your system
revolution
Fanael wrote:
These are called conservative garbage collectors, because they conservatively assume that any value can be a pointer, therefore, they can mistake an integer for a pointer and think that an object is reachable even though it's not. On the other hand, most GCs found in things like JVMs, .NET, etc. are precise: they know whether something is a pointer or not, thus they won't get fooled by an integer that just happened to have a valid value for a pointer, thus they always properly detect unreachable objects. If they don't, chances are they're buggy. And then, the fact they don't detect all unreachable objects is probably your smallest problem.
Even assuming that the GC is perfect and never errs, it still doesn't meet the second problem of unused memory still allocated but not freed. This means other processes can't use that memory. There is no way to reach into the offending process and force it to run the GC. And even if we could reach in to run the GC remotely then we need some sort of method to know when it has finished so that we can carry on and allocate our memory. It is all very tricky and imperfect.
Fanael wrote:
And... FF doesn't use a garbage collector.
Okay, so that just means FF is awfully buggy.
Post 23 Apr 2011, 14:07
View user's profile Send private message Visit poster's website Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
Quote:
Okay, so that just means FF is awfully buggy.

Or designed for machines with plenty of free RAM.
Post 23 Apr 2011, 14:28
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17271
Location: In your JS exploiting you and your system
revolution
vid wrote:
Or designed for machines with plenty of free RAM.
Or meant for people that run nothing else except the browser AND with plenty of free RAM.

Even so: plenty <<< infinite. Something has to give eventually
Post 23 Apr 2011, 14:35
View user's profile Send private message Visit poster's website Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
Does the usage really keep increasing indefinitely?
Post 23 Apr 2011, 14:44
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17271
Location: In your JS exploiting you and your system
revolution
vid wrote:
Does the usage really keep increasing indefinitely?
Once it gets to 300MB (after 5-7 days usually) I have to restart it since I need the RAM back. So I can't really answer your question first hand, but I have seen reports around that mention about FF using 1.5GB with all tabs closed so it would appear that it might well be indefinite. Classic memory leakage I would imagine.
Post 23 Apr 2011, 14:49
View user's profile Send private message Visit poster's website Reply with quote
Enko



Joined: 03 Apr 2007
Posts: 678
Location: Mar del Plata
Enko
Made a simple experiment:

I opened this pages in this order using firefox and chrome:

www.google.com
www.flatassembler.net
www.warnet.ws
www.youtube.com


At the last page, firefox was consuming 62Mb of memory. After 1 minut 52MB.

Google chrome (I have no plugins) had 3 proccess runing:
The fist one: 66MB
The second:25MB
the third: 14 MB
I hade only 1 tab opened.

Total memory usage: aprox 100MB.

For those who are thinking why 3 proccesses...I can answer only have of this question.

The fist one, should be the main tab.
The other one, should be the flashplugin, its runs on independen thread.

the last one, the third... I have no idea, i dont have plugins instaled, each plugin runs on different thread.

When I start chrome 2 threads are started... ni idea why, perhaps the pdf plugin or the java... no idea.
Post 23 Apr 2011, 15:25
View user's profile Send private message Reply with quote
Enko



Joined: 03 Apr 2007
Posts: 678
Location: Mar del Plata
Enko
Here another bullshit experiment with firefox:

I open it, google is the start page.
Memory Usage: 37MB. And its not growing. 5 minutes passed, still 37MB.

I write somthing on url bar, then delete it, memory usage: 39MB.
Waited 5 minuts doing nothing, memory usage 55MB.


tried the same thing 3 times, same result.
Post 23 Apr 2011, 15:45
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
this really does smell with something buggy (such as loading hints for completion of partially typed URL). Worth of reporting IMO.
Post 23 Apr 2011, 16:07
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 2913
Location: [RSP+8*5]
bitRAKE
V8 (the JVM used in Chrome) has an efficient GC. this outlines some problem/solutions working with V8 GC.
Post 24 Apr 2011, 03:57
View user's profile Send private message Visit poster's website Reply with quote
Madis731



Joined: 25 Sep 2003
Posts: 2141
Location: Estonia
Madis731
Don't all browsers keep closed tabs in cache to be quickly restored through Ctrl+Shift+T (File > Recently Closed Tabs in Seamonkey)?
Something to look at: URL = about:memory (works in Firefox, Chrome is not that interesting) or URL = about:cache (works in Mozilla browsers).

Try to keep F5 pressed down - interesting "saw-tooth" animation. Memory usage keeps growing and then jumps down.
Post 25 Apr 2011, 12:01
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar.

Powered by rwasa.