Lower RES Memory usage!

I got a new Microsoft Surface,  and the memory usage on RES is too much for the poor tablet.  So,  I decided to fork RES and see if I can reduce memory overhead for loading new pages.   If this patch goes well,  I'd like to further reduce RES's memory usage. 

This patch could use more testing.  Loading 10 pages with the current RES takes roughly 804M or ram,  after this patch the page consumed 764M with the same dataset.  Still needs more work,  but there is a noticeable reduction in memory usage with normal browsing habits.

Improvements:
- A bloomfilter is the most efficient way of keeping track of dupes.  A bloomfilter doesn't need to store the full string in order to keep track of uniqueness.  Additionally,  insertion into a bloom filter is always O(1), where as dictionaries need to be expanded when they become full.

-  "Hiding" elements with CSS doesn't make them go away.  These elements need to be deleted properly to free up memory. Hiding elements lead to a **nasty** memory leak.  Reddit has enough re-posts,  there is no need for RES to introduce duplicates to the feed.

A bloom filter that can support 100k entries is still a very small
structure.    Let me do some more testing to get an optimal number before
release.


On Mon, Dec 8, 2014 at 10:28 PM, erikdesjardins <notifications@github.com>
wrote:

> In lib/modules/neverEndingReddit.js
> <https://github.com/honestbleeps/Reddit-Enhancement-Suite/pull/1844#discussion-diff-21507832>
> :
>
> > @@ -101,10 +97,16 @@ modules['neverEndingReddit'] = {
> >  	go: function() {
> >  		if ((this.isEnabled()) && (this.isMatchURL())) {
> >  			// modified from a contribution by Peter Siewert, thanks Peter!
> > -			if (typeof modules['neverEndingReddit'].dupeHash === 'undefined') modules['neverEndingReddit'].dupeHash = {};
> > +			// bloom filter to store 100,000 elements with a .01 failure rate.
> > +			// http://0pointer.net/blog/projects/bloom.html
> > +			// m = -n*ln(p)/(ln(2)^2)
> > +			// m ~= 958505
> > +			// k = 0.7*m/n
> > +			// k ~= 7
> > +			if (typeof modules['neverEndingReddit'].bloomfilter === 'undefined') modules['neverEndingReddit'].bloomfilter = new BloomFilter(958505,7);
>
> We might want to make this much smaller than 100,000, since we shouldn't
> see more than about 1000 entries per page (I haven't seen more than 1050 in
> testing).
>
> Also, style: we prefer full block if-statements instead of shorthand.
> i.e. if (foo) bar; becomes:
>
> if (foo) {
>     bar;
> }
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/honestbleeps/Reddit-Enhancement-Suite/pull/1844/files#r21507832>
> .
>