This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 40950 - [JDK1.5.0] OutOfMemory Error while trying to print.
Summary: [JDK1.5.0] OutOfMemory Error while trying to print.
Status: CLOSED FIXED
Alias: None
Product: platform
Classification: Unclassified
Component: Help System (show other bugs)
Version: 4.x
Hardware: PC Windows ME/2000
: P2 blocker (vote)
Assignee: _ tboudreau
URL:
Keywords: JDK_SPECIFIC
: 41215 (view as bug list)
Depends on:
Blocks:
 
Reported: 2004-03-12 11:15 UTC by lenkite
Modified: 2008-12-22 22:56 UTC (History)
6 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
ide log (10.05 KB, text/plain)
2004-03-12 11:16 UTC, lenkite
Details
screenshot (143.70 KB, image/jpeg)
2004-03-12 11:56 UTC, lenkite
Details
Fix for the problem (1.16 KB, patch)
2004-03-25 15:29 UTC, _ tboudreau
Details | Diff
core javahelp with patch (103.05 KB, application/octet-stream)
2004-03-25 15:34 UTC, _ tboudreau
Details
Diff of patch for Win and Metal (1.14 KB, patch)
2004-06-21 14:40 UTC, mslama
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description lenkite 2004-03-12 11:15:58 UTC
I am using Netbeans 3.6 beta on jdk1.5.0 beta
As soon, as I clicked the print button on the help
system on the node marked as "Editor shorcuts", it
hung with a OutOfMemoryError - despite the fact
that I had a lot of RAM available.
I am attaching the IDE log and a screenshot of the
error
Comment 1 lenkite 2004-03-12 11:16:35 UTC
Created attachment 13959 [details]
ide log
Comment 2 Milan Kubec 2004-03-12 11:49:25 UTC
I suppose that printing is in core.
Comment 3 lenkite 2004-03-12 11:56:53 UTC
Created attachment 13960 [details]
screenshot
Comment 4 lenkite 2004-03-12 12:05:09 UTC
oops, more explicitly it occurs, when I hit the Page Setup button in
the JavaHelp system. The problem seems to always occur.
Comment 5 lenkite 2004-03-12 12:07:26 UTC
And the best part is that the Page Setup and Print dialog still turns
up.. and I am able to print.
Comment 6 _ tboudreau 2004-03-12 12:43:46 UTC
Printing from JavaHelp is implemented by JavaHelp - NetBeans 
code isn't really involved.  I know there were some problems in the past (supposed to be 
fixed) with endless loops while printing if the page break was in just the right place.  This 
looks more like a bug in AWT though.

The message is a little weird:
java.lang.OutOfMemoryError: null pData
which suggests it's not actually an OutOfMemoryError - usually these are generated by the 
JVM, and there's no message text - this one was intentionally thrown.  Now, it could mean 
the operating system was out of some other kind of resource like graphics handles;  or it 
could just mean someone made a really poor choice as to what kind of exception to throw 
- tough to say, it happens inside the JDK's peer implementation.

Milan, could someone in QA try to reproduce this on a win2k machine?
Comment 7 Marian Mirilovic 2004-03-12 13:38:27 UTC
Milan, 
please look at this ... thanks in advance.
Comment 8 Milan Kubec 2004-03-12 13:43:05 UTC
I might, but currently I'm out of time.
Comment 9 lenkite 2004-03-14 17:11:19 UTC
If it helps you guys, I'll install jdk1.5 and Netbeans 3.6 beta on
another Win 2K machine and check whether the problem can be reproduced
there as well. Will do that at work tommorow or the day after.
Comment 10 Milan Kubec 2004-03-15 10:28:01 UTC
Yes, it would really help us a lot, thanks.
Comment 11 pzajac 2004-03-15 10:35:24 UTC
Milan, don't by lazzy:-))
I can reproduce it on my win2k machine. It was tested on jdk
1.5.0-beta-2-b42. 
Comment 12 _ tboudreau 2004-03-25 11:36:48 UTC
*** Issue 41215 has been marked as a duplicate of this issue. ***
Comment 13 _ tboudreau 2004-03-25 14:30:12 UTC
This is reproducible on Win2K or WinXP, in NetBeans 3.5.1 or 3.6.  The OOME is thrown in 
native code in the dialog peer implementation.  Something changed in that 
implementation for JDK 1.5 which causes it to now throw an exception.

As far as I can tell, what is probably null is the operating system window handle for the 
owner of the dialog.  I am prepared to file a JDK bug on this, but they would be well within 
their rights not to fix it, because what NetBeans is doing is pretty crazy.  What is going on:

Because AWT dialogs are application-modal, whenever a new modal dialog is shown, if the 
help is showing, a new non-modal child dialog of the modal dialog is created, and the 
help component is reparented into that, so the help stays enabled.

The problem appears to be that there is no check to see if the parent of the new modal 
dialog *is* the help window (in which case it being disabled is perfectly fine - it will either 
be the Print dialog or the Print Setup dialog).  So, just as the print dialog is being created, 
its parent frame disappears in a puff of smoke, and a new child dialog is added.  I can't 
really imagine this strangeness being a thing the JDK team would want to officially support 
- which is why I say they'd be well within their rights to close any such bug report as 
WONTFIX.

I'll try to put together a fix for 3.6.
Comment 14 _ tboudreau 2004-03-25 15:28:47 UTC
Okay, I've got a workaround.  Unfortunately, it's a bit ugly - we can't check if the print 
dialogs' owner is the help window's frame, because they use the no-owner constructor 
(owner is an invisible offscreen JFrame).  So there's no way to make a connection to the 
invoker from it.

The diff I will attach simply checks the class of the dialog, and if it's an AWT print dialog or 
print settings dialog, it does not play with the windows.  This means that the help window 
will also be disabled when you select Print/Page Setup from the main File menu, but this is 
probably a reasonable trade off.  Presumably with 1.6 or something in between, we will 
have better AWT window modality support, and the dancing help window will be a thing of 
the past.
Comment 15 _ tboudreau 2004-03-25 15:29:40 UTC
Created attachment 14150 [details]
Fix for the problem
Comment 16 _ tboudreau 2004-03-25 15:34:01 UTC
Created attachment 14151 [details]
core javahelp with patch
Comment 17 Jesse Glick 2004-03-25 15:39:05 UTC
Does this happen on non-Win platforms? If not, the attached patch
looks like a reasonable workaround to me.

Backdating version field based on Tim's comment.
Comment 18 _ tboudreau 2004-03-25 15:45:58 UTC
Hasn't been reported on other platforms.  Just tried it on Apple, and it works correctly to 
open the dialog, but throws the following when the print dialog is *closed*, after which it 
is impossible to ever display the help dialog again:

java.lang.IllegalStateException: Can't dispose InputContext while it's active
	at sun.awt.im.InputContext.dispose(InputContext.java:601)
	at java.awt.Window$1DisposeAction.run(Window.java:560)
	at java.awt.Window.dispose(Window.java:570)
	at java.awt.Dialog.disposeImpl(Dialog.java:638)
	at java.awt.Dialog.dispose(Dialog.java:634)
	at org.netbeans.modules.javahelp.JavaHelp.displayHelpInFrame(JavaHelp.java:186)
	at org.netbeans.modules.javahelp.JavaHelp.eventDispatched(JavaHelp.java:403)
	at java.awt.Toolkit$SelectiveAWTEventListener.eventDispatched(Toolkit.java:2136)
	at java.awt.Toolkit$ToolkitEventMulticaster.eventDispatched(Toolkit.java:2030)
	at java.awt.Toolkit$ToolkitEventMulticaster.eventDispatched(Toolkit.java:2029)
	at java.awt.Toolkit$ToolkitEventMulticaster.eventDispatched(Toolkit.java:2029)
	at java.awt.Toolkit$ToolkitEventMulticaster.eventDispatched(Toolkit.java:2029)
	at java.awt.Toolkit$ToolkitEventMulticaster.eventDispatched(Toolkit.java:2029)
	at java.awt.Toolkit$ToolkitEventMulticaster.eventDispatched(Toolkit.java:2029)
	at java.awt.Toolkit.notifyAWTEventListeners(Toolkit.java:1988)
	at java.awt.Component.dispatchEventImpl(Component.java:3530)
	at java.awt.Container.dispatchEventImpl(Container.java:1627)
	at java.awt.Window.dispatchEventImpl(Window.java:1606)
	at java.awt.Component.dispatchEvent(Component.java:3477)
[catch] at java.awt.EventQueue.dispatchEvent(EventQueue.java:479)
Comment 19 Marian Mirilovic 2004-03-29 11:18:49 UTC
Not reproducible on Linux RH9 / JDK1.5.0(b43)/NB3.6 RC2(200304251830)
Comment 20 Marian Mirilovic 2004-03-29 12:43:39 UTC
Not reproducible on Sol8 / JDK1.5.0(b43)/NB3.6 RC2(200304251830)
Comment 21 pzajac 2004-03-31 16:21:17 UTC
Not reproducible in JDK1.5.0(b44). But printing in Java help on linux
doesn't work. 
Comment 22 _ ttran 2004-03-31 21:14:00 UTC
Tim's patch integrated into release36.

It's not in the CVS trunk (promo-d)
Comment 23 _ ttran 2004-04-04 21:03:36 UTC
fixed in 3.6, not in trunk, version -> promo-D
Comment 24 _ tboudreau 2004-04-19 14:06:35 UTC
Reassigning to Marek, new owner of output window and help system
Comment 25 mslama 2004-05-17 12:21:50 UTC
Tim, Shall I commit this fix to main trunk?
Comment 26 _ ttran 2004-06-20 22:25:51 UTC
Marek, please retest it w/ the latest JDK 1.5 beta and integrate Tim's
patch to trunk.  Thx
Comment 27 mslama 2004-06-21 14:39:39 UTC
It does not work also on Metal. I had to add one more condition for
Metal. Tim please check on MacOS. I commit fix and attach diff.
Reassigning to Tim to check on MAcOS and close.
Comment 28 mslama 2004-06-21 14:40:32 UTC
Created attachment 15886 [details]
Diff of patch for Win and Metal
Comment 29 mslama 2004-06-21 14:47:53 UTC
Modified:
/cvs/core/javahelp/src/org/netbeans/modules/javahelp/JavaHelp.java,v 
<--  JavaHelp.java
new revision: 1.23; previous revision: 1.22

Tim on MacOS dialogs are shown but JavaHelp window is blinking. It
looks like JavaHelp window in unnecessarily hidden and shown again
when print dialogs are shown. Just minor issue but perhaps it might be
fixed in the same way.
Comment 30 _ tboudreau 2004-07-21 12:47:02 UTC
Fixed on apple too now.

Checking in src/org/netbeans/modules/javahelp/JavaHelp.java;
/cvs/core/javahelp/src/org/netbeans/modules/javahelp/JavaHelp.java,v  <--  
JavaHelp.java
new revision: 1.25; previous revision: 1.24
done
Comment 31 Marian Mirilovic 2004-09-01 14:40:32 UTC
verified in [nb_dev](200408311800)