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.
 

b4x-de

Active Member
Licensed User
Longtime User
I am glad you could solve your problem. But does your solution implies, that we have a memory leak in the commenly used B4XLoadingIndicator?
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
I am glad you could solve your problem. But does your solution implies, that we have a memory leak in the commenly used B4XLoadingIndicator?
I am also experienced high memory and CPU usage in one of my app then I removed it. I think the animation takes a lot of resources (my CPU only has intel integrated graphic) and should not load more than one loading indicator views at the same layout at same time.
 
Upvote 0

jahswant

Well-Known Member
Licensed User
Longtime User
? @Erel could you look into this ?
 
Upvote 0

fhersof

Member
Please upload a small program that reproduces it.
This is a basic example of what happens, when starting the form opens and closes with the animations, everything starts correctly then it starts to get slow and then slower and very slow and ends up in a crash. As this application is very light, it reached close to 1000 openings, in my complete original application it only reached up to 25 openings
 

Attachments

  • bloqueos.zip
    4.2 KB · Views: 125
Upvote 0

fhersof

Member
I haven't ran the project as the error is clear. You are making more and more forms.

Closing a form only hides it. Don't initialize it again. Simply call Show.
Thanks Erel, I have added the condition:
B4X:
    If formprod.IsInitialized = False Then
        formprod.Initialize("formprod", 1010, 680) ''le asigno el tamaño es que se mostrara.horizontal y vertical.
        formprod.RootPane.LoadLayout("theprods") ''Load the layout file cargo pantalla.
        formprod.Title = "PRODUCTS"
        formprod.Resizable = False ''bloqueo para que no se pueda cambiar de tamaño.
        formprod.SetFormStyle("UNDECORATED")''quito la barra de titulo original con sus botones de minimizar maximizar cerrar.
    End If
    formprod.Show
After this everything works perfectly, excuse my ignorance, I thought that when using the .close of the form it was completely deleted.
Is there a way to delete it completely and not just hide it?
 
Upvote 0

virpalacios

Active Member
Licensed User
Longtime User
Hi, I have a task scheduler composed by three clv, inside each one, a panel in inserted with labels and buttons. The clvs get refreshed by a timer every minute. After some time memory is getting hi and program scratch by out of heap memory error. I did some improvements by destroying some objects in clvs loading. So I conclude that this clvs are filled with composed objects, alter clear them memory do not get release, using simple objects (just text no panels) everthing goes ok, I will post a code post for example.

Best Regards
 
Upvote 0
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…