Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #15798
| Path | csiph.com!usenet.pasdenom.info!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!news.tele.dk!news.tele.dk!small.news.tele.dk!npeer.de.kpn-eurorings.net!npeer-ng0.de.kpn-eurorings.net!newsfeed.arcor.de!newsspool4.arcor-online.net!news.arcor.de.POSTED!not-for-mail |
|---|---|
| Content-Type | text/plain; charset="ISO-8859-1" |
| Message-ID | <1908140.bfDClWI3Sb@PointedEars.de> (permalink) |
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
| Reply-To | Thomas 'PointedEars' Lahn <cljs@PointedEars.de> |
| Organization | PointedEars Software (PES) |
| Date | Sat, 08 Sep 2012 14:21:02 +0200 |
| User-Agent | KNode/4.4.11 |
| Content-Transfer-Encoding | 7Bit |
| X-Face | %i>XG-yXR'\"2P/C_aO%~;2o~?g0pPKmbOw^=NT`tprDEf++D.m7"}HW6.#=U:?2GGctkL,f89@H46O$ASoW&?s}.k+&.<b';Md8`dH6iqhT)6C^.Px|[=M@7=Ik[_w<%n1Up"LPQNu2m8|L!/3iby{-]A+#YE}Kl{Cw$\U!kD%K}\2jz"QQP6Uqr],./"?;=4v |
| Face | iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAGFBMVEXTxa4RFk5dUWANED8PFEfy7+MGBiW+n3ZNF/QuAAACaElEQVQ4jVXUwVOcMBQG8Dc7Rc4PUntdWV2uxjDpGaGeozOp1woar4jd5t/v9wLstMwsA/ntlxdCAgUc1hjTc9/JCZfGoo3wG3HdmdAWrIJRHe7GM/TmpY5VFefuVcAkkPbLIaN8rmPmjloyZxgyR3GuJ4K0AGtJ2htz8o7yqikm759fldQXaMpbDzjKAG+8v+AugVTOPO5DOjLvGtUYQwh0CPjnVMyGd+8/GfUB5nLKJDD2aLDh5HYyMDJGDwQIo2ZmZcKbowNmAdB/AzyFhrmF2MHRb0QJJfaAnwGB6orZhoykLzJtGwF/xpYxI1dswomiUj3gTuAIqCn/4C7cULwGNBtwMTk3Y4LfKB5YUaOKBKYtpplm7u0vip8tU1NWWyI/7XdcSuIDoMt6rVHMWT0DbjHPGqDqZVSa6zleLcUTcIKLoMv3ueJluALtAo9B302zPPlrtiVScRdCjXvVh3e3JpYa/jjkuC9N+LrBMlz/eAN4eQijX2EdLo6c5tGGHwLyHFtXk89dDGHwCVhG9T0S/j55AhRZgkMCmUQXJ49TnS1wnQDvw0eAh9ICeMmEFbCnPMFzjAvsWoEWEFdYEx+S0MoUZ1gT1wId8+AF3Bl2OoEu906AUHx5VLw/gXYg/x84loOah/2UYNrgiwSwGO7RfUzVBbx/kgpckumGOi6QirtD6gkLTitbnxNol47S2jVc2vsN5kPqaAHT8uUdAJM4v/DanjYOwmUjWznGfwB7sGtAtor5BgofDuzaRj4kSQAqDakTsKORa3Q3xKi3gE1fhl71KRMqrdZ2AWNNg/YOhQyrVBnb+i+nEg4bsDA+egAAAABJRU5ErkJggg== |
| Subject | Re: XHR: Passing Parameters to a ready-state-change Function |
| Newsgroups | comp.lang.javascript |
| References | <09ef48tfsgucbl7m49ggao3be5r0kb7v13@4ax.com> <k2akj4$bca$1@news.albasani.net> <hs9i48l1r77mh36nj9jq6jofp9h837o0pu@4ax.com> <timstreater-90133A.09150507092012@news.individual.net> <mf9k489u8j684s2unrfbaaq62idmti1dsi@4ax.com> <timstreater-DBAFA6.19140107092012@news.individual.net> <1399593.26SQpm16Mm@PointedEars.de> <timstreater-F16A12.23085507092012@news.individual.net> <1704778.3LbdHo29L0@PointedEars.de> <timstreater-A11629.11114908092012@news.individual.net> |
| Followup-To | comp.lang.javascript |
| MIME-Version | 1.0 |
| Lines | 91 |
| NNTP-Posting-Date | 08 Sep 2012 14:21:03 CEST |
| NNTP-Posting-Host | ddd174c6.newsspool1.arcor-online.net |
| X-Trace | DXC=57ZBk5C1aje[F<50eo:0knic==]BZ:afn4Fo<]lROoRankgeX?EC@@`KPeR?^YhTLgDZm8W4\YJNlR=i2=[N6Y6jgLn>?b02nZcZ^k`AEH0:`` |
| X-Complaints-To | usenet-abuse@arcor.de |
| Xref | csiph.com comp.lang.javascript:15798 |
Followups directed to: comp.lang.javascript
Show key headers only | View raw
Tim Streater wrote:
> Thomas 'PointedEars' Lahn <PointedEars@web.de> wrote:
>> Tim Streater wrote:
>> > Thomas 'PointedEars' Lahn <PointedEars@web.de> wrote:
>> >> Tim Streater wrote:
>> >> > And each time you call your ajax function you'll get a new one.
>> >> Which is not a bad thing.
>> >>
>> >> > AIUI, although my knowledge of closures is a bit limited, each one
>> >> > will live forever unless you explicitly dump it when you've finished
>> >> > with it. By setting it to null, it'll get garbage-collected
>> >> > subsequently.
>> > I leave that to the browser to worry about.
>> IOW, you are incompetent enough to not care about your users.
>
> Fuck off.
Why I am even talking to you? You were incompetent when I scorefiled you
years ago and you have not changed a bit. See below.
>> >> Wishful thinking. There is no guarantee that garbage collection will
>> >> commence before all browser windows are closed.
>> >
>> > [snip]
>> >
>> >> > request = null;
>> >>
>> >> With regard to memory efficiency and probably even runtime efficiency,
>> >> it is far better to reuse an existing XHR object once the request has
>> >> been
>> >> processed. See JSX:http.js [1] for example.
>> >
>> > No doubt, but I may have several such requests outstanding at any given
>> > moment and have no desire to manage a set of XHR objects.
>>
>> So you would rather not manage them and let them waste memory, one by
>> one,
>> eating it up until the browser application exits, in the worst case.
>> Where is the logic in that?
>
> They don't waste memory, they get garbage collected.
When? *That* is the question you have to ask yourself, and the answer to
that is: You *cannot* know. So be slow to create new objects.
> If I didn't set them to null they certainly would waste memory.
You have a serious misconception of how these implementations work and how
garbage collection works, in general. Which is unsurprising given your
statement on the top (and yet you still think you know what is going on?).
If you are assigning `null' or any other non-reference value to a property,
what you are doing is merely to reduce the number of references to an
object. (Because, you know, an object can have, and usually will have,
*several* references to it. References are values here.)
If, and only if, the number of references to an object reaches zero, the
object becomes eligible for garbage collection (that is, the memory it uses
can be freed, to be used by other data). It can (but does not need to) be
*marked* for garbage collection then.
When garbage collection actually happens, the memory reserved for *marked*
objects is freed. Not before. In the best case, garbage collection happens
when cyclically, defined by a probability algorithm, the engine cleans up
after itself. The medium case is that garbage collection happens only when
the engine runs out of free memory. In the worst case, it happens only when
the engine is terminated, which is when the browser process is terminated
(i.e., all windows are closed).
This is not a fantasy. There have been and still are badly designed Web
applications using client-side scripting eating up memory until the browser
and operating system became virtually unusable (driving the swap size to the
extreme) because people were not aware of the objects and closures they
created and the applications and browsers ran for a longer time.
Bottom line: Creating objects in the current browser session reserves
memory. Creating more objects reserves more memory. Reserving memory
reduces free memory. Assigning `null' to a property that previously had as
value a reference to an object does _not_ *immediately* free that memory.
It certainly does _not_ *trigger* garbage collection. It merely *allows*
for garbage collection, if, and only if, all conditions I mentioned above
are met.
PointedEars
--
var bugRiddenCrashPronePieceOfJunk = (
navigator.userAgent.indexOf('MSIE 5') != -1
&& navigator.userAgent.indexOf('Mac') != -1
) // Plone, register_function.js:16
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
XHR: Passing Parameters to a ready-state-change Function Gene Wirchenko <genew@ocis.net> - 2012-09-05 13:53 -0700
Re: XHR: Passing Parameters to a ready-state-change Function Jim T. <x@y.z> - 2012-09-05 17:46 -0400
Re: XHR: Passing Parameters to a ready-state-change Function Gene Wirchenko <genew@ocis.net> - 2012-09-05 17:30 -0700
Re: XHR: Passing Parameters to a ready-state-change Function Jim T. <x@y.z> - 2012-09-05 20:55 -0400
Re: XHR: Passing Parameters to a ready-state-change Function Jim T. <x@y.z> - 2012-09-05 21:43 -0400
Re: XHR: Passing Parameters to a ready-state-change Function Jim T. <x@y.z> - 2012-09-05 21:49 -0400
Re: XHR: Passing Parameters to a ready-state-change Function Stefan Weiss <krewecherl@gmail.com> - 2012-09-06 18:56 +0200
Re: XHR: Passing Parameters to a ready-state-change Function Gene Wirchenko <genew@ocis.net> - 2012-09-06 10:55 -0700
Re: XHR: Passing Parameters to a ready-state-change Function Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-09-06 21:38 +0200
Re: XHR: Passing Parameters to a ready-state-change Function Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-09-06 21:49 +0200
Re: XHR: Passing Parameters to a ready-state-change Function Gene Wirchenko <genew@ocis.net> - 2012-09-06 15:49 -0700
Re: XHR: Passing Parameters to a ready-state-change Function Tim Streater <timstreater@greenbee.net> - 2012-09-07 09:15 +0100
Re: XHR: Passing Parameters to a ready-state-change Function Gene Wirchenko <genew@ocis.net> - 2012-09-07 09:58 -0700
Re: XHR: Passing Parameters to a ready-state-change Function Tim Streater <timstreater@greenbee.net> - 2012-09-07 19:14 +0100
Re: XHR: Passing Parameters to a ready-state-change Function cezary.tomczyk@gmail.com - 2012-09-07 13:51 -0700
Re: XHR: Passing Parameters to a ready-state-change Function Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-09-08 00:52 +0200
Re: XHR: Passing Parameters to a ready-state-change Function cezary.tomczyk@gmail.com - 2012-09-07 16:32 -0700
Re: XHR: Passing Parameters to a ready-state-change Function Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-09-08 09:48 +0200
Re: XHR: Passing Parameters to a ready-state-change Function Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2012-09-08 02:09 -0700
Re: XHR: Passing Parameters to a ready-state-change Function Tim Streater <timstreater@greenbee.net> - 2012-09-08 11:09 +0100
Re: XHR: Passing Parameters to a ready-state-change Function Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2012-09-08 03:39 -0700
Re: XHR: Passing Parameters to a ready-state-change Function John G Harris <john@nospam.demon.co.uk> - 2012-09-08 15:00 +0100
Re: XHR: Passing Parameters to a ready-state-change Function Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-09-07 23:44 +0200
Re: XHR: Passing Parameters to a ready-state-change Function Tim Streater <timstreater@greenbee.net> - 2012-09-07 23:08 +0100
Re: XHR: Passing Parameters to a ready-state-change Function Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-09-08 00:46 +0200
Re: XHR: Passing Parameters to a ready-state-change Function Tim Streater <timstreater@greenbee.net> - 2012-09-08 11:11 +0100
Re: XHR: Passing Parameters to a ready-state-change Function Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-09-08 14:21 +0200
Re: XHR: Passing Parameters to a ready-state-change Function Tim Streater <timstreater@greenbee.net> - 2012-09-08 17:06 +0100
Re: XHR: Passing Parameters to a ready-state-change Function Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-09-08 20:41 +0200
Re: XHR: Passing Parameters to a ready-state-change Function Dr J R Stockton <reply1236@merlyn.demon.co.uk.invalid> - 2012-09-09 20:04 +0100
Re: XHR: Passing Parameters to a ready-state-change Function Gene Wirchenko <genew@ocis.net> - 2012-09-09 18:40 -0700
Re: XHR: Passing Parameters to a ready-state-change Function "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2012-09-10 07:21 +0000
Re: XHR: Passing Parameters to a ready-state-change Function Tim Streater <timstreater@greenbee.net> - 2012-09-10 09:03 +0100
Re: XHR: Passing Parameters to a ready-state-change Function "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2012-09-10 13:59 +0000
Re: XHR: Passing Parameters to a ready-state-change Function Tim Streater <timstreater@greenbee.net> - 2012-09-10 15:35 +0100
Re: XHR: Passing Parameters to a ready-state-change Function "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2012-09-10 22:42 +0000
Re: XHR: Passing Parameters to a ready-state-change Function Scott Sauyet <scott.sauyet@gmail.com> - 2012-09-11 10:09 -0700
Re: XHR: Passing Parameters to a ready-state-change Function Tim Streater <timstreater@greenbee.net> - 2012-09-11 22:42 +0100
csiph-web