How to set the compiler to handle thousand loops ?

T

tobleron

Hi,

Hi, I'm using NetBeans IDE 6.1 to develope my application. My
application works well when deals with loops of reading 52,000 lines
of waveform data. But it fails when reads 104,000 of waveform data.
How to set the IDE to handle multiple loops like this ? I'm using
FileOutputStream function, while-do, and ByteBuffer function in this
case. Please advise. Thank you in advance.
 
R

Roedy Green

Hi, I'm using NetBeans IDE 6.1 to develope my application. My
application works well when deals with loops of reading 52,000 lines
of waveform data. But it fails when reads 104,000 of waveform data.
How to set the IDE to handle multiple loops like this ? I'm using
FileOutputStream function, while-do, and ByteBuffer function in this
case. Please advise. Thank you in advance.

see http://mindprod.com/applet/fileio.html

for to generate code for all manner of ways of reading your data.

You also might consider CSV format.
see http://mindprod.com/jgloss/csv.html
 
R

RedGrittyBrick

tobleron said:
Hi,

Hi, I'm using NetBeans IDE 6.1 to develope my application. My
application works well when deals with loops of reading 52,000 lines
of waveform data. But it fails when reads 104,000 of waveform data.
How to set the IDE to handle multiple loops like this ? I'm using
FileOutputStream function, while-do, and ByteBuffer function in this
case. Please advise. Thank you in advance.

Please read http://www.catb.org/~esr/faqs/smart-questions.html

- Define "it fails".
- Where is your code?
- What makes you think an IDE places any restriction on loop size?
 
T

tobleron

Please readhttp://www.catb.org/~esr/faqs/smart-questions.html

- Define "it fails".
- Where is your code?
- What makes you think an IDE places any restriction on loop size?

@All,

Here is the the error code shows by NetBeans IDE :

Caused by: java.lang.OutOfMemoryError: Java heap space
at ....

For mor detail, my code is to generating DICOM file which is contains
waveform data of ECG record. The waveform data source is a text file
that contains hundreds or even thousands lines of ECG signal. Each
line contains 12 ECG channels. So what my code do is :

- first : opens the text file BufferedReader function.
- second : uses FileOutputStream function to write the streamed bytes.
- third : reads line by line (by using scanner and loop function) then
split each line to get the 12 channels value.
- forth : switch to little endian encoding to write the channel value
bytes (DICOM using little endian encoding for the waveform value).

The third and forth steps are looped from the first line until the end
line of the text file.

I said : it fails, because the process is stopped and the IDE shows
error message above.

I thought the IDE can not handle thousands times of looping, because
the code works well in 52,000 lines data, but when I doubled the
lines, the process is stopped and the error message is occured. And it
was "out of memory".

So, I want to know, is there any way to make adjustment in IDE, may be
for buffer setting, or some thing like that ? I used 512 MB of RAM,
and I seek another possible ways other than "add more RAMs". Please
advise.
 
L

Lew

tobleron said:
@All,

Here is the the error code shows by NetBeans IDE :

Caused by: java.lang.OutOfMemoryError: Java heap space
at ....

You would see the same error even running outside the IDE.

Just out of curiosity, why aren't you quoting the entire error message?

OOME means you haven't allocated enough memory for the process, or else you
are wasting memory in your code (my bet). Allocate more memory or else fix
the bug.
For mor detail, my code is to generating DICOM file which is contains

For more detail:
Check out, read thoroughly, and follow the advice of <http://sscce.org/>.

Why the heck do you ignore advice, then ask for more help?
waveform data of ECG record. The waveform data source is a text file
that contains hundreds or even thousands lines of ECG signal. Each
line contains 12 ECG channels. So what my code do is :

SSCCE, please. Description is useless.
- first : opens the text file BufferedReader function.
- second : uses FileOutputStream function to write the streamed bytes.
- third : reads line by line (by using scanner and loop function) then
split each line to get the 12 channels value.
- forth : switch to little endian encoding to write the channel value
bytes (DICOM using little endian encoding for the waveform value).

The third and forth steps are looped from the first line until the end
line of the text file.

Gee, if we could only see the code we could tell you where your mistake is.
I said : it fails, because the process is stopped and the IDE shows
error message above.

You said too little to let us help.
I thought the IDE can not handle thousands times of looping, because

Your problem has nothing to do with the IDE.
the code works well in 52,000 lines data, but when I doubled the
lines, the process is stopped and the error message is occured. And it
was "out of memory".

You are not releasing memory after each loop.
So, I want to know, is there any way to make adjustment in IDE, may be
Nope.

for buffer setting, or some thing like that ? I used 512 MB of RAM,
and I seek another possible ways other than "add more RAMs". Please
advise.

You got advice that you ignored.
<http://sscce.org/>

Generally speaking, your code is allocating memory that it never releases.
Release unused objects and they will be collected, and you won't get the OOME.

<http://sscce.org/>
<http://sscce.org/>
<http://sscce.org/>
 
M

Martin Gregorie

So, I want to know, is there any way to make adjustment in IDE, may be
for buffer setting, or some thing like that ? I used 512 MB of RAM, and
I seek another possible ways other than "add more RAMs". Please advise.
So, if I understand your description, what you're doing is:

read file into a buffer
for each line in the buffer
split into channels
re-code into DICOM (little endian) format
append line to output buffer
end-for
write output buffer to a file

If I'm wrong, please describe your logic as an SSCE or in pseudocode.

Otherwise, why buffer entire files when you appear to be processing the
data line by line? Read from the file line by line and output each
converted line as its completed and your memory problems will vanish.
 
R

RedGrittyBrick

tobleron said:
@All,

Here is the the error code shows by NetBeans IDE :

Caused by: java.lang.OutOfMemoryError: Java heap space
at ....

For mor detail, my code is to generating DICOM file which is contains
waveform data of ECG record. The waveform data source is a text file
that contains hundreds or even thousands lines of ECG signal. Each
line contains 12 ECG channels. So what my code do is :

- first : opens the text file BufferedReader function.
- second : uses FileOutputStream function to write the streamed bytes.
- third : reads line by line (by using scanner and loop function) then
split each line to get the 12 channels value.
- forth : switch to little endian encoding to write the channel value
bytes (DICOM using little endian encoding for the waveform value).

The third and forth steps are looped from the first line until the end
line of the text file.

I said : it fails, because the process is stopped and the IDE shows
error message above.

I thought the IDE can not handle thousands times of looping, because
the code works well in 52,000 lines data, but when I doubled the
lines, the process is stopped and the error message is occured. And it
was "out of memory".

So, I want to know, is there any way to make adjustment in IDE,

You don't need to.
may be
for buffer setting, or some thing like that ? I used 512 MB of RAM,
and I seek another possible ways other than "add more RAMs".

You probably need much LESS RAM if you fix your coding.
Please advise.

See Martin Gregorie's advice. With more or less the *same* *small*
amount of memory usage you should be able to process 1 line, 1000 lines,
1000000 lines, 1000000000 lines or almost any number of lines (each
containing twelve channel values).

Just make sure your FileOutputStream is being flushed periodically and
that you are not "packratting" objects
(http://mindprod.com/jgloss/packratting.html)
 
T

tobleron

@All,

You can download my source code at http://www.artikelilmiah.com/NewECGRecord.zip
The waveform data can be downloaded at http://www.artikelilmiah.com/12ecgsample2-104000.zip
and http://www.artikelilmiah.com/12ecgsample2-52000.zip

Here is the complete error message :

init:
deps-jar:
compile:
run:
Nov 1, 2008 11:25:26 AM org.jdesktop.application.LocalStorage getId
WARNING: unspecified resource Application.id using Main
Nov 1, 2008 11:25:26 AM org.jdesktop.application.LocalStorage getId
WARNING: unspecified resource Application.vendorId using
UnknownApplicationVendor
Exception in thread "AWT-EventQueue-0" java.lang.Error:
java.lang.reflect.InvocationTargetException
at
org.jdesktop.application.ApplicationAction.actionFailed(ApplicationAction.java:
859)
at
org.jdesktop.application.ApplicationAction.noProxyActionPerformed(ApplicationAction.java:
665)
at
org.jdesktop.application.ApplicationAction.actionPerformed(ApplicationAction.java:
698)
at
javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:
1995)
at javax.swing.AbstractButton
$Handler.actionPerformed(AbstractButton.java:2318)
at
javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:
387)
at
javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
at
javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:
236)
at
java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:
272)
at java.awt.Component.processMouseEvent(Component.java:6041)
at javax.swing.JComponent.processMouseEvent(JComponent.java:
3265)
at java.awt.Component.processEvent(Component.java:5806)
at java.awt.Container.processEvent(Container.java:2058)
at java.awt.Component.dispatchEventImpl(Component.java:4413)
at java.awt.Container.dispatchEventImpl(Container.java:2116)
at java.awt.Component.dispatchEvent(Component.java:4243)
at
java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4322)
at
java.awt.LightweightDispatcher.processMouseEvent(Container.java:3986)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:
3916)
at java.awt.Container.dispatchEventImpl(Container.java:2102)
at java.awt.Window.dispatchEventImpl(Window.java:2440)
at java.awt.Component.dispatchEvent(Component.java:4243)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
at
java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:
273)
at
java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:
183)
at
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:
173)
at
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
at
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:
121)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
org.jdesktop.application.ApplicationAction.noProxyActionPerformed(ApplicationAction.java:
662)
... 27 more
Caused by: java.lang.OutOfMemoryError: Java heap space
at java.util.Arrays.copyOfRange(Arrays.java:3209)
at java.lang.String.<init>(String.java:216)
at java.lang.StringBuffer.toString(StringBuffer.java:585)
at ecgterminal3.NewECGRecord.okGenerate(NewECGRecord.java:
2429)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
org.jdesktop.application.ApplicationAction.noProxyActionPerformed(ApplicationAction.java:
662)
at
org.jdesktop.application.ApplicationAction.actionPerformed(ApplicationAction.java:
698)
at
javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:
1995)
at javax.swing.AbstractButton
$Handler.actionPerformed(AbstractButton.java:2318)
at
javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:
387)
at
javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
at
javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:
236)
at
java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:
272)
at java.awt.Component.processMouseEvent(Component.java:6041)
at javax.swing.JComponent.processMouseEvent(JComponent.java:
3265)
at java.awt.Component.processEvent(Component.java:5806)
at java.awt.Container.processEvent(Container.java:2058)
at java.awt.Component.dispatchEventImpl(Component.java:4413)
at java.awt.Container.dispatchEventImpl(Container.java:2116)
at java.awt.Component.dispatchEvent(Component.java:4243)
at
java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4322)
at
java.awt.LightweightDispatcher.processMouseEvent(Container.java:3986)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:
3916)
at java.awt.Container.dispatchEventImpl(Container.java:2102)
at java.awt.Window.dispatchEventImpl(Window.java:2440)
at java.awt.Component.dispatchEvent(Component.java:4243)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
at
java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:
273)
at
java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:
183)
BUILD SUCCESSFUL (total time: 1 minute 58 seconds)

So, please help. As I mentioned before, it works well on 52000 lines
of waveform data (and under), but fails when trying to read 104000
lines of waveform data.
 
T

tobleron

Looks like somehow my previous message double-posted.  Sorry.  Not sure how
that happened.


This download gave me a .class file, not source.

@Lew

I've tried to describe my problem as clear as I can. What kind of
<http://sscce.org/> that you want ? If you see in that .class file,
you'll know that I just put my code that I mentioned before in
okGenerate() function.
 
L

Lew

I've tried to describe my problem as clear as I can. What kind of
<http://sscce.org/> that you want ? If you see in that .class file,
you'll know that I just put my code that I mentioned before in
okGenerate() function.

It is very inconvenient to decompile a .class file. Why not provide source?
 
L

Lew

Donkey said:
That zip contains nothing more than the compiled class file. Useless.

The OP was already told that. Their response:
If you see in that .class file,
you'll know that I just put my code that I mentioned before in
okGenerate() function.

With these reminders, perhaps they'll consider providing source.
 
M

Mark Space

tobleron said:
I've tried to describe my problem as clear as I can. What kind of
<http://sscce.org/> that you want ?

The short, self-contained compilable kind. One class, provide "input"
for the file read so we don't need some sort of external file, try to
get the file down to 60 lines or less. It should be possible for you.

Also make sure your error (OutOfMemory) occurs in your example before
posting it.
If you see in that .class file,
you'll know that I just put my code that I mentioned before in
okGenerate() function.

No one wants to read through 3000 lines of source and a dozen classes to
debug your problem. You are asking for help, you do the work to make it
obvious to us what is going on. Post a ->"short"<- example, not your
entire code base.
 
A

Arne Vajhøj

Donkey said:
That zip contains nothing more than the compiled class file. Useless.

Not useless.

But it is asking people that want to help waste time
decompiling.

Very few will do that.

Arne
 
T

tobleron

@all,

I don't understand what you mean with compiled class file. I sent the
zip file that contains the original code. Some parts are written by
the NetBeans, but for the action function, I wrote it by hand. I don't
understand why you said that I need you all to decompile it ? I don't
need you to decompile it.

First time, I avoid to send the code because I know, it will bothering
you with that complicated code. So I tried to just describe the flow.
But you need the original code, so I sent it. But now you said I sent
too much. Another person said I sent too less. I really don't
understand what should I provide to make you understand how to solve
this looping problem.

Anyway, I tried to provide just a part of the code that been my
concern problem, which is the looping part. You can see it at
http://www.artikelilmiah.com/looping.zip I hope you can understand
what I'm concerning and can give me a better solution.

@Martin Gregorie
Hmm... I think I did just like your suggestion. Or maybe it because of
the size of the waveform data source (approx 13 MB) ?
 
L

Lew

tobleron said:
I don't understand what you mean with compiled class file.

The zip file contained a .class file comprising byte code. It contained no
text file at all, much less source code.
 
J

Joshua Cranmer

tobleron said:
@all,

I don't understand what you mean with compiled class file. I sent the
zip file that contains the original code. Some parts are written by
the NetBeans, but for the action function, I wrote it by hand. I don't
understand why you said that I need you all to decompile it ? I don't
need you to decompile it.

jcranmer@quetzalcoatl /tmp $ unzip NewECGRecord.zip
Archive: NewECGRecord.zip
inflating: NewECGRecord.class
jcranmer@quetzalcoatl /tmp $

It contains only a class file. javap agrees with me that it's a class file.
First time, I avoid to send the code because I know, it will bothering
you with that complicated code. So I tried to just describe the flow.
But you need the original code, so I sent it. But now you said I sent
too much. Another person said I sent too less. I really don't
understand what should I provide to make you understand how to solve
this looping problem.

Provide us with NewECGRecord.java. Not .class, .java.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,444
Messages
2,571,709
Members
48,796
Latest member
Greg L.
Top