B4J Question program made in B4J after a while it gets slow and crashes

Status
Not open for further replies.

fhersof

Member
Hello, please a little help, I have created a program in B4J, the program is a point of sale, at the beginning of the day it works fine but then in the afternoon it gets slow and crashes.
He revisado el código en las rutinas que más se ejecutan y desconfío del siguiente código ya que desconozco su funcionamiento interno:
product search:
Private Sub btnSearch_Click
    Wait For (Dialog.ShowTemplate(SearchTemplate, "", "", "CERRAR")) Complete (Result As Int)
    If Result = xui.DialogResponse_Positive Then
        codeselec = MidExtract(SearchTemplate.SelectedItem,"[","]")
    End If
    txtcodebar.RequestFocus
End Sub


and when starting the program in AppStart I call this routine that loads about 8,000 products:
This is called only once when starting the program:
Sub CargaData_Busqueda
    Base = MainForm.RootPane
    If Dialog.IsInitialized = False Then
        Dialog.Initialize (Base)
    End If
    Dialog.Title = "Busqueda Por Nombre"
    SearchTemplate.Initialize
    If Items99.IsInitialized = False Then
        Items99.Initialize
    End If
    Items99.Clear
    ''*********************************************************************************
    segcsr = conn.ExecQuery("SELECT Codigo, Nombre From productos")
    Do While segcsr.NextRow
        codeselec = segcsr.GetString("Codigo")
        elname = segcsr.GetString("Nombre")
        Items99.Add(elname & " " & "[" & codeselec & "]")
    Loop
    segcsr.Close
    codeselec = ""
    elname = ""
    ''*********************************************************************************
    SearchTemplate.SetItems(Items99)
End Sub

Thank you very much and I will be attentive to any guidance.
 

peacemaker

Expert
Licensed User
Longtime User
HDD or SSD sectors corruption ?...
Some huge template folder overloading...
 
Upvote 0

fhersof

Member
¿Qué sucede cuando se bloquea? ¿Hay algo en los registros?
Hi Erel, The mentioned case happens to the clients, in my computer it does not happen since it is difficult for me to spend one day using the system as the clients do, they tell me that in the main bar where the name appears: Does not Respond
 
Upvote 0

EnriqueGonzalez

Well-Known Member
Licensed User
Longtime User
they tell me
If you are using the packager, you can execute the debug that is a losing side the executable, this will open a CMD screen. I always ask to my customers that if it fails, they should send me a screenshot of that screen. (or allow me access to the PC via a remote desktop)

If you are running the jar directly, you can execute the jar from CMD and the logs will appear.
 
Upvote 0

jmon

Well-Known Member
Licensed User
Longtime User
Upvote 0

fhersof

Member
What happens when it crashes? Is there anything in the logs?
Hello Erel, I was able to capture the logs when the program freezes and then closes, please if you can help me. Thank you so much.
the next record is repeated several times:
java.lang.ArrayIndexOutOfBoundsException: -1
    at java.util.ArrayList.elementData(ArrayList.java:418)
    at java.util.ArrayList.get(ArrayList.java:431)
    at javafx.scene.Parent.updateCachedBounds(Parent.java:1580)
    at javafx.scene.Parent.recomputeBounds(Parent.java:1524)
    at javafx.scene.Parent.impl_computeGeomBounds(Parent.java:1377)
    at javafx.scene.layout.Region.impl_computeGeomBounds(Region.java:3078)
    at javafx.scene.Node.updateGeomBounds(Node.java:3556)
    at javafx.scene.Node.getGeomBounds(Node.java:3509)
    at javafx.scene.Node.getLocalBounds(Node.java:3457)
    at javafx.scene.Node.impl_intersectsBounds(Node.java:4992)
    at javafx.scene.layout.Region.impl_pickNodeLocal(Region.java:2931)
    at javafx.scene.Node.impl_pickNode(Node.java:4891)
    at javafx.scene.Scene$MouseHandler.pickNode(Scene.java:3900)
    at javafx.scene.Scene$MouseHandler.access$1600(Scene.java:3486)
    at javafx.scene.Scene.pick(Scene.java:1942)
    at javafx.scene.Scene.access$6700(Scene.java:159)
    at javafx.scene.Scene$MouseHandler.process(Scene.java:3712)
    at javafx.scene.Scene$MouseHandler.access$1500(Scene.java:3486)
    at javafx.scene.Scene.impl_processMouseEvent(Scene.java:1762)
    at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2495)
    at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:350)
    at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:275)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$350(GlassViewEventHandler.java:385)
    at com.sun.javafx.tk.quantum.GlassViewEventHandler$$Lambda$155/803506.get(Unknown Source)
    at com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:404)
    at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:384)
    at com.sun.glass.ui.View.handleMouseEvent(View.java:555)
    at com.sun.glass.ui.View.notifyMouse(View.java:927)
    at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at com.sun.glass.ui.win.WinApplication.lambda$null$145(WinApplication.java:101)
    at com.sun.glass.ui.win.WinApplication$$Lambda$38/23749442.run(Unknown Source)
    at java.lang.Thread.run(Thread.java:745)
 
Upvote 0

fhersof

Member
1. Are you using the Threading library? Or any specialized library that runs your code on other threads?

2. Switch to latest version of JavaFX: https://www.b4x.com/android/forum/threads/jgooglemaps-library.56744/#content
I just ran the program from B4J in Debug mode, I used the program up to the point where it froze and then it closed, in the logs I got this record:
B4X:
java.lang.OutOfMemoryError: Java heap space
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "Glass/Prism Shutdown Hook"
 
Upvote 0

fhersof

Member
Looks like your PC is running out of resources. How many RAM does it have?
I have 7 gb ram and intel core i5 processor, but when the program is frozen the computer works perfectly in other applications or youtube videos, the same thing happens in my computer and in others it is the same
 
Upvote 0

agraham

Expert
Licensed User
Longtime User
The Java Virtual Machine is running out of its allocated heap space. This won't affect other programs. It looks like you have a memory leak in your code or in one of the libraries that you use. You can try to find it with this program.
 
Upvote 0

fhersof

Member
To all those who gave me some guidance to solve my problem, thank you very much, because they helped me expand my thinking, I was finally able to solve it and I want to share the solution in case it happens to someone:
I created a timer that would open and then close a form that I suspected had something to do with the blocking, every 5 seconds and when it was 40 seconds open the system would slow down and end up frozen and then it would close with memory problem logs.
I was eliminating elements of the design of the form and of the code to see which generated the problem, The surprise was that when I eliminated a panel that contained 2 animations of B4XLoadingIndicator, the crashes ended and everything was resolved. I tried it, letting it open and close about 3000 times and I didn't have any errors.
 
Upvote 0

EnriqueGonzalez

Well-Known Member
Licensed User
Longtime User
I remember something like this happened to me. The error occurred because I was trying to access a control after I closed the form

At that moment, java cleans the form from memory and trying the access any node will fail.

Hope that is your case, so you can fix it quickly.
 
Upvote 0

fhersof

Member
Thank you all very much, the case is considered closed because I already solved it, I have published what was the cause and what was the solution, but I do not know why it does not appear in the publication
 
Upvote 0
Status
Not open for further replies.
Top