harry-g / fairpos

Automatically exported from code.google.com/p/fairpos
0 stars 0 forks source link

Invisible Out of Memory with many articles #70

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
With ETL data now loaded, we get many
java.lang.OutOfMemoryError: Java heap space
when browsing through the article groups in sales panel.
E.g. Katalog Handwerk->Lost+Found

The application just seems to freeze or slow down, but does not show any error.

Original issue reported on code.google.com by harald.g...@gmail.com on 13 Jul 2012 at 9:31

GoogleCodeExporter commented 8 years ago

Original comment by harald.g...@gmail.com on 13 Jul 2012 at 2:55

GoogleCodeExporter commented 8 years ago
No OutOfMemoryError / slowdowns observed, but there is something weird for sure 
- seems like every new opening of search dialog creates new instaces of its 
classes (see JProductFinder - pic 1) and some unwanted reference remains there 
even after closing the dialog - in some render classes it seems. Curiously, 
there is 'JProductFinder' more times (different instances) in the reference 
chain - this seems like if clicking on button in one search dialog creates 
another copy of this search dialog.

Solutions which I think of:
* change JProductFinder to be singleton (or could there be more searches opened 
simultaneously?)
* use weak references somehow - so the reference which causes trouble now is 
not preventing GC after the search window is closed
* kill the problematic event listeners / renderers somehow - together with 
closing the search window

Observed (pic 2): 12x JProductFinder ~ 30 MB each, (each holding reference to 
JList); FairPOS 300 MB mem total

@Harald: where did you see out of memory error? In netbeans console? Or is 
there some log?

Original comment by benes.vi...@gmail.com on 17 Jul 2012 at 9:23

Attachments:

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
A-hah - I was confused - I was opening search dialog (magnifier icon in 
Sales)... Now I can reproduce the thing - selecting 'Katalog' at bottom -> 
Katalog-Handwerk -> Lost & Found...

See: JCatalog.java (line 198):
jcurrTab.addButton(new ImageIcon(tnbbutton.getThumbNailText(prod.getImage(), 
getProductLabel(prod))), new SelectedAction(prod));       

There is 33 kB image (145 x 58 x 32bpp) created per product. 25000 products => 
1 GB.

Original comment by benes.vi...@gmail.com on 19 Jul 2012 at 8:16

GoogleCodeExporter commented 8 years ago
That's what I feared. So we can only see that the categories stay smaller.
Anyway you could:
* fix the memory leak mentioned in the search
* for the 2500 products - display an error message box and stop the application

Original comment by harald.g...@gmail.com on 21 Jul 2012 at 8:26

GoogleCodeExporter commented 8 years ago
> * for the 2500 products - display an error message box and stop the 
application

another solution could be: if there are more than 1000 products, use the same 
icon for all of them (I think it worked - the icons were the same, item names 
were correct on them & memory was not sky-rocketing... just the 25000 products 
take maybe 10 s to load from db)

Original comment by benes.vi...@gmail.com on 24 Jul 2012 at 7:49

GoogleCodeExporter commented 8 years ago
Yea, also sounds good. And maybe output a error or warning to log, in case 
someone wants to know where the icons went...

Original comment by harald.g...@gmail.com on 24 Jul 2012 at 9:13

GoogleCodeExporter commented 8 years ago
r119 - if there are more than 1000 items, icon is set to be same for all of 
them (also the text needs to be same for all), the buttons work - they add the 
correct items to ticket

Details:
 10 s - loading of products from db (this will be there even with no buttons (from icons) displayed afterwards)
 13 s - then - creating buttons from that 25000 items - these buttons are taking approx 30 MB (same icon is used) forever (during the whole run of app)

 ...another option is to display no products in list if there are more than eg. 1000 (or to display only one button with the warning displayed on it)

Original comment by benes.vi...@gmail.com on 24 Jul 2012 at 11:33

GoogleCodeExporter commented 8 years ago
please test, it can stay like this (all icons - but all are the same & all have 
the same text) maybe or I can implement something else

lowering priority to Medium

Original comment by benes.vi...@gmail.com on 3 Oct 2012 at 5:56

GoogleCodeExporter commented 8 years ago
Unfortunately like this it is of no use.
The text is replaced by "xxx items - no icons!".
So you cannot identify the article anymore.
I understand that it seems that the text is part of the icon.
But like this, it would be better not to open the category.
Any better idea? How to put a text field there or such?

Original comment by harald.g...@gmail.com on 2 Feb 2013 at 6:01

GoogleCodeExporter commented 8 years ago
Maybe as quick solution for now, back to your proposal:
>or to display only one button with the warning displayed on it
But somehow it must be ensured that this will not be added to the cart when 
clicked...

Original comment by harald.g...@gmail.com on 2 Feb 2013 at 6:11

GoogleCodeExporter commented 8 years ago
r146
It just displays error that there is too much items in the category. None icons 
are displayed.

If you want to localize the message, please prepare the messages & I will use 
them in the code. Use {0} if you want to put the number of items in the 
message, eg.:

msg.toomuchitems=There are {0} items, it is too much! Bye.

Original comment by benes.vi...@gmail.com on 10 Feb 2013 at 3:05

GoogleCodeExporter commented 8 years ago
OK, i put there "message.toomuchitems" in DE and EN.
Please add.
Two drawbacks are that it still takes minutes (because of ineficcient 
openbravopos code maybe) and that the message is only displayed first time you 
enter the category (so as the POS mostly always stays on, it will virtually 
never appear).
So let's head for a better solution for the next milestone.

Original comment by harald.g...@gmail.com on 10 Feb 2013 at 4:49

GoogleCodeExporter commented 8 years ago

Original comment by harald.g...@gmail.com on 10 Feb 2013 at 4:49

GoogleCodeExporter commented 8 years ago
r152 
Now the error is displayed everytime + category is not opened. 
Please test.

> (...)takes minutes(...)
The delay is the duration of the SQL query - we query all product which have 
some category from db. 
See getProductCatalog() in DataLogicSales.java (line:138)
No can do (unless we try some SQL hacking).

Original comment by benes.vi...@gmail.com on 10 Feb 2013 at 5:27

GoogleCodeExporter commented 8 years ago
Ok for now - as said above let's head for a better solution for the next 
milestone.

>The delay is the duration of the SQL query 
That would be a bad reference for Postgresql...
I tried, in the app it takes > 2minutes, in pgAdminIII SQL console <5 sec. with 
below SQL.
But let's not waste more time on it now... next milestone!

SELECT P.ID, P.REFERENCE, P.CODE, P.NAME, P.ISCOM, P.ISSCALE, P.PRICEBUY, 
P.PRICESELL, P.TAXCAT, P.CATEGORY, P.ATTRIBUTESET_ID, P.IMAGE, P.ATTRIBUTES, 
P.PRICESELL_RECOMMENDED, P.MANUAL_PRICE FROM PRODUCTS P, PRODUCTS_CAT O WHERE 
P.ID = O.PRODUCT AND P.CATEGORY = 'LF001' ORDER BY O.CATORDER, P.NAME

Original comment by harald.g...@gmail.com on 10 Feb 2013 at 5:49