Closed Bug 468791 Opened 16 years ago Closed 13 years ago

Eval function eval("test();") memory leak

Categories

(Core :: JavaScript Engine, defect)

x86
Windows XP
defect
Not set
critical

Tracking

()

RESOLVED WORKSFORME

People

(Reporter: urdddd, Unassigned)

Details

Attachments

(3 files)

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1b2) Gecko/20081201 Firefox/3.1b2
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1b2) Gecko/20081201 Firefox/3.1b2

The eval() javascript function leaks memory badly.

Happens in Firefox 3.0 and 3.1 on Windows Xp and Linux (Ubuntu 8.10).

Very easy test case:

function test() {
}	
	
while (true) {
  eval("test();");	
}

Fill memory in a couple of minutes.

Reproducible: Always

Steps to Reproduce:
1. Load the following page:
<html>
<head></head>
<body>
<script>
function test() {
}	
	
while (true) {
	eval("test();");	
}
</script>
</body>
</html>

2. Watch as the memory used by Firefox grows and grows pretty quickly.

Actual Results:  
Firefox's RAm footprint just keeps growing indefinitely.

Expected Results:  
Firefox should use a constant amount of memory for that operation.


If you do this:


function test() {
}	
	
while (true) {
  test();	
}

There is no memory leak. The problem lies in the eval() function.
Version: unspecified → 3.1 Branch
This is wfm, no memory leak with FF3.0.4 on vista.

Do you get the same in the Firefox safemode ?
Assignee: nobody → general
Component: General → JavaScript Engine
Product: Firefox → Core
QA Contact: general → general
Version: 3.1 Branch → unspecified
To make this more useful, please follow the steps found at http://new.quality.mozilla.org/bug-writing-guidelines and report back with your results.
I've followed the indications described here:
http://new.quality.mozilla.org/bug-writing-guidelines

I've downloaded and installed FF 3.1b2 (US English) again.

I've started FireFox in safe mode from the commande line (firefox -safe-mode) and the problem persists.

I've create a new profile (firefox.exe -ProfileManager) and then started in safe mode again with the new profile. When loading the test page there is one thing new: a waring dialog appears ("Warning: Unresponsive script") asking me if I want to stop the script execution. Before this dialog appears the memory when up as usual but falls back when the dialog appears. For the purpose of this test, I check the "Don't ask me again" checkbox to let the script execute for a longer period of time. The results is that the memory used goes up and up and in about a minute FireFox 3.1 beta 2 consumes 1GB of RAM.

I've also tried running the test page with the new profile in normal mode (not safe) and the problem is the same.

I've also tried the "leak-gauge.html" but there is nothing to report.

Lastly here are some info of my computer:

Manufacturer :	Dell Precision T3400
Mainboard :	Dell 0TP412
Chipset :	Intel X38
Processor :	Intel Core 2 Quad Q9400 @ 2666 MHz
Physical Memory :	4096 MB (4 x 1024 DDR2-SDRAM )
Video Card :	NVIDIA Quadro FX 1700
Hard Disk :	ARRAY (500 GB)
DVD-Rom Drive :	HL-DT-ST DVD-ROM DH10N
DVD-Rom Drive :	HL-DT-ST DVD+-RW GSA-H73N
Monitor Type :	Dell Computer DELL 1908FP - 19 inches
Network Card :	Broadcom Corp NetXtreme BCM5754 Gigabit Ethernet
Operating System :	Microsoft Windows XP Professional 5.01.2600 Service Pack 3
DirectX :	Version 9.0c
Just to give more information:

In FF 2.0.0.18: 
 - no problem

In FF 3.0.4: 
 - problem in normal mode.
 - no problem in safe mode.

In FF 3.1 beta 2: 
 - problem in normal mode.
 - problem in safe mode.
Attached file Original Test case
This is the html page that I use to reproduce the memory leak.
Comment on attachment 352526 [details]
Original Test case

<html>
<head></head>
<body>
<script>
function test() {
}    

while (true) {
    eval("test();");    
}
</script>
</body>
</html>
Comment on attachment 352526 [details]
Original Test case

strange characters appears in the test case when I uploaded it ... please copy and paste the code in the comment #0
I've downloaded today:
firefox-3.2a1pre.en-US.win32.installer.exe    Dec 11 14:26   7429k

After the installation I've create a new profile.

I've launched firefox in the normal mode (using the new profile) and, just like last time, I see the warning dialog ("Unresponsive script") after a while.
I tell it to continue and check the "Don't ask me again" checkbox. Like last time, the memory goes up quickly before the dialog appear. Once it appears, the memory goes back to normal levels. After clickqing "continue" the memory goes up and up indefinitely and quickly.

I close firefox and restart it in safe-mode. Exactly the same thing happens.

So to recap:

In firefox-3.2a1pre.en-US.win32.installer.exe (Dec 11): 
 - problem in normal mode.
 - problem in safe mode.
Attachment #352526 - Attachment mime type: text/html → text/html;charset=utf-16
Status: UNCONFIRMED → RESOLVED
Closed: 16 years ago
Resolution: --- → DUPLICATE
There is no recursion involved in my test case so I don't know if this is a
duplicate of the other bug.
In addition the other bug was reported in 2006 (I guess under FF 2) and I have no memory problems under FF 2.0.0.18
Oops, I misread the closing brackets. The other bug was reported with Fx 3.0a1, it says so in comment 0.
Status: RESOLVED → UNCONFIRMED
Resolution: DUPLICATE → ---
Can someone update the status please?
For Christmas I wish that someone else confirms the bug. Then the status could be changed to NEW or, dare I dream ... ASSIGNED!  :-)

Merry Christmas to all of you!
Nothing new here. Happy new year anyway.
Please don't post spamy comments on bugs. The status will be updated when and if someone is able to reproduce this issue, and see why.
Sorry
(In reply to comment #6)
> Comment on attachment 352526 [details]
> Original Test case

I can't reproduce high memory using FF 4.0b8 20101010. but memory does vary by 30MB, which seems a bit much.  chrome doesn't change at all.
Summary: Eval function memory leak → Eval function eval("test();") memory leak
I cannot reproduce this in the browser or in the shell using 75817:b354d9b3e9e1.  Test conducted on 64bit linux with optimizations on and off in the shell.
Status: UNCONFIRMED → RESOLVED
Closed: 16 years ago13 years ago
Resolution: --- → WORKSFORME
I can see similar symptoms in Firefox 49.0.1. 

See my stackoverflow question.
http://stackoverflow.com/questions/39773622/memory-leak-using-window-eval-in-firefox

To sumarize my observations:
I run the code below for 9 hours in Firefox/Chrome/Edge and watch used memory.

<html>
<head></head>
<body>
    <script>
        function test() {
            // do something important
        }   
        setInterval(
            function() {
                window.eval("test();");
            }, 
            100
        );
    </script>
</body>
</html>

         at start      after cca 9 hours   browser version
         -------------------------------------------------
Edge:    0.28MB        0.28MB              38.14393.0.0
Chrome:  1.70MB        1.90MB              53.0.2785.116
Firefox: 0.25MB        115.3MB             49.0.1

As you can see Firefox memory growed up. So I thing there is a bug.
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: