jEdit Community - Resources for users of the jEdit Text Editor
GC out of memory with macro.
Submitted by jazminstewart on Tuesday, 19 January, 2010 - 19:29
Hi, first message here. I have been using jEdit for a short time. I've found it as a replacement for UltraEdit and coding is not my need.

Running Macros/Scripts is what I need to do from time to time to clean up files coming in different formats.

I've had many memory issues with jEdit. But this is something I can't solve. It seems to be jEdit related but I think some of you may help.

I have a 162MB text file, opening chews about >330MB (the Heap is at 2GB now)

I run this Macro (avoiding some obvious constants and declarations) (SEE BELOW)

It works fine, but the memory ramps to 2GB, stays like that for about 30 minutes until I get a message from BeanShell that GC has run out of heap memory.

As you can see, my code does not "retain" things in memory, so I don't see why it's doing that.

I've set the Autosave time to "0" and Undo to "0".




while (SearchAndReplace.find(view))
{
SearchAndReplace.setSearchString("\\d+\\.\\d+");
SearchAndReplace.find(view); //Find first number in line
strTemp = textArea.getSelectedText(); //Copy to a String
SearchAndReplace.setSearchString("\\s+.*\\s+(?=(\\d|-))");
SearchAndReplace.find(view); //Find some other numbers

textArea.backspace(); //Erase that

//Add spaces until caret gets to the column it should be
while ( (textArea.getCaretPosition()-textArea.getLineStartOffset(textArea.getCaretLine()))
< 19)
{
textArea.setSelectedText(" ");
}

textArea.setSelectedText(strTemp); //Paste the previously copied number

//Add spaces until caret gets to a specified column
while ( (textArea.getCaretPosition()-textArea.getLineStartOffset(textArea.getCaretLine()))
< 32)
{
textArea.setSelectedText(" ");
}

SearchAndReplace.setSearchString("SOME\\s+");
}


Thanks!
Comment viewing options
Select your preferred way to display the comments and click 'Save settings' to activate your changes.
Status Bar widget
by Robert Schwenn on Fri, 22/01/2010 - 14:30
Chances are, that Your problem is caused by a newly identified memory leak: The "selection-length" Status Bar widget seems to allocate memory every time it's updated. And in Your example this is very often the case, I think. So, please try the following:

1. Goto "Global Options -> Status Bar -> Widgets Tab" and remove the "selection-length" widget
2. Restart jEdit

Maybe the macro runs without problems now. I'm curious.

Robert
 
Robert, thanks for your comme
by jazminstewart on Mon, 25/01/2010 - 11:59
Robert, thanks for your comments.

I have to add that I've tried inserting r.gc() each 1000 iterations. Didn't helped.

About your comments. I don't have that there. I will transcript the Widgets tab:

(
mode
,
fold
,
encoding
)
wrap
multiSelect
rectSelect
overwrite
lineSep
buffersets
memory-status
errors
clock


That's all folks!
 
other scripting tools
by d_l on Fri, 22/01/2010 - 18:20
If you are stuck you might try scripting in AutoIT ..

http://www.autohotkey.com

Here are some Commando AutoIT scripts I found searching around ..

http://jedit4autoit.thorsten-willert.de/

Another useful tool (but not free) is TEXTools from http://www.fireflysoftware.com

TEXTools scripts can be run via command line in Commando scripts or macros.
 
Thanks for your suggestion.
by jazminstewart on Mon, 25/01/2010 - 12:15
Thanks for your suggestion.

I prefer to "fix" this issue since some times I will prefer direct scripting over the editor. But I might use that tool in the future for other purposes.

Also I expect some performance out of scripting straight into the text editor that usually doint it "graphically" is slower and might forbid using the mouse and keyboard in another software while the script runs.

I guess I forgot to mention I'm using 4.4 pre1.

But since 4.3 is buggy and jEdit people decided to send 4.3 development version as a final version I guess there is no issue on using 4.4 pre1
 
about 4.3
by Robert Schwenn on Mon, 25/01/2010 - 21:05
>>> But since 4.3 is buggy and jEdit people decided to send 4.3 development version as a final version I guess there is no issue on using 4.4 pre1

I'm with You in the evaluation of jEdit 4.3. But jEdit 4.3 will get bug fixes (4.3.1 will come soon) and 4.4preX will stay in development with new features as all the 4.3 pre-releases have been.

This way the jEdit 4.3 branch will become less buggy then 4.4 pre-releases I think.

Robert
User login
Browse archives
« November 2024  
MoTuWeThFrSaSu
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
 
Poll
Are you interested in language packs for jEdit?
Yes, and I could help maintain translations
26%
Yes, I'd like to have translations
32%
Indifferent
35%
No, that'd be bad (please comment)
7%
Total votes: 1093
Syndication
file   ver   dls
German Localization light   4.4.2.1   101634
Context Free Art (*.cfdg)   0.31   46062
BBEdit scheme   1.0   18601
JBuilder scheme   .001   18502
ColdFusion scheme   1.0   18031
R Edit Mode - extensive version   0.1   17481
Advanced HTML edit mode   1.0   16213
Matlab Edit Mode   1.0   16075
jEdit XP icons   1.0   15236
XP icons for jEdit   1.1   14300