unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Daniel Colascione <dancol@dancol.org>
To: Eli Zaretskii <eliz@gnu.org>, Mario Valencia <mariovalspi@gmail.com>
Cc: 20220@debbugs.gnu.org
Subject: bug#20220: severe memory leak on emacs 24.4.1
Date: Wed, 01 Apr 2015 00:50:48 -0700	[thread overview]
Message-ID: <551BA358.2000404@dancol.org> (raw)
In-Reply-To: <83mw2vzui9.fsf@gnu.org>

[-- Attachment #1: Type: text/plain, Size: 2377 bytes --]

On 03/29/2015 08:35 AM, Eli Zaretskii wrote:
>> Date: Sat, 28 Mar 2015 17:39:38 -0600
>> From: Mario Valencia <mariovalspi@gmail.com>
>>
>> to reproduce it, i create a small emtpy html document. then i evaluate the
>> following expression:
>>
>> (dotimes (i 100) (browse-url-of-file))
>>
>> This causes emacs to start opening the file using google chrome. In the task
>> manager, i can see emacs' memory usage go up by about 5 megabytes each time a
>> tab is opened. When it opens about 30 tabs, emacs is using 138 megabytes of
>> memory, and it gives the error below.
>> the translation is something like this: "ShellExecute failed: Storage space
>> insufficient to process this command"
>> My harddrive has enough storage space btw.
> 
> (The error is not about disk storage, it's about reserving the address
> space in virtual memory.)
> 
> FWIW, I don't see such a large memory increase when I reproduce this,
> I see something around 1MB, sometimes 1.5MB.  But I didn't try on
> Windows 8.
> 
> Anyway, Emacs doesn't allocate any memory when it calls the
> ShellExecute function, so I see no way we could leak something here.
> 
> My guess would be that invoking ShellExecute causes Windows to start a
> thread in the context of the Emacs process, and reserve 8MB of stack
> space for that thread.  (On one of 3 systems I tried your recipe, I
> actually saw a thread per invocation, each thread was running some
> function inside shlwapi.dll, the shared library which implements the
> ShellExecute API.)  The memory actually used by that thread for its
> stack is much smaller than 8MB, of course, but Windows attempts to
> reserve 8MB of address space for its stack.
> 
> The 8MB figure comes from the way we link Emacs: we need such a large
> stack due to regular expressions, stack-based Lisp objects, and GC
> which is deeply recursive.  By default, each thread reserves the same
> stack space as the program to which it belongs.  For threads we launch
> in Emacs, we override the default 8MB stack space by a much smaller
> value, but we have no such control on threads that Windows itself
> starts on behalf of the Emacs process.

Do we need the lisp thread to be the main thread? What about calling
CreateThread very early in initialization with a large dwStackSize,
leaving other threads with default-sized stacks?


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

  parent reply	other threads:[~2015-04-01  7:50 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-28 23:39 bug#20220: severe memory leak on emacs 24.4.1 Mario Valencia
2015-03-29  6:01 ` Daniel Colascione
2015-03-29  6:04   ` Mario Valencia
2015-03-29 15:15     ` Eli Zaretskii
2015-03-29 15:35 ` Eli Zaretskii
2015-03-31  2:07   ` Mario Valencia
2015-03-31 12:46     ` Eli Zaretskii
2015-03-31 21:03       ` Stefan Monnier
2015-04-01  2:19         ` Mario Valencia
2015-04-01  2:47           ` Eli Zaretskii
2015-04-01 14:24             ` Eli Zaretskii
2015-04-01  7:53           ` Daniel Colascione
2015-04-01 14:26             ` Eli Zaretskii
2015-04-01 16:01               ` Daniel Colascione
2015-04-01 16:05                 ` Eli Zaretskii
2015-04-04 20:24                   ` Mario Valencia
2015-04-04 21:19                     ` Eli Zaretskii
2015-04-10 11:16                       ` Mario Valencia
2015-04-10 11:24                         ` Eli Zaretskii
2015-04-10 11:29                           ` Eli Zaretskii
2015-04-10 11:33                             ` Mario Valencia
2015-04-10 11:36                               ` Eli Zaretskii
2015-04-10 12:58                                 ` Stefan Monnier
2015-04-10 13:13                                   ` Eli Zaretskii
2015-04-23  7:18                           ` Eli Zaretskii
2015-04-01  7:50   ` Daniel Colascione [this message]
2015-04-01 14:25     ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=551BA358.2000404@dancol.org \
    --to=dancol@dancol.org \
    --cc=20220@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=mariovalspi@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).