B4J Question WEBSocket Server Memory usage

Discussion in 'B4J Questions' started by swissmade, Feb 16, 2015.

  1. swissmade

    swissmade Active Member Licensed User

    Hi all,

    I have a small Websocket Server where about 8 connections at the same time are made.
    To be sure that th web-page is updated all the time I have a refresh time of the web page set to 10 minutes. The Web-page disconnects and connects again after this time has reach.

    Now the problem.
    The Server start with a Memory usage from about 30mb and threads usage 27.
    Startup the server with this code below.
    #VirtualMachineArgs: -Xms128m -Xmx128m
    After a while the server reach more then this 128mb and I get a out of memory error.
    Threats are also go high to 400-500 threads
    So I have the idea that there still old unused connections busy with something.
    How can I delete this unused connections and free up my resources.

    Many thanks for help
  2. Erel

    Erel Administrator Staff Member Licensed User

    The online example which is running on this server, was running for 4 months without any memory leak (I stopped it because the server was updated).

    You will need to post your project as it seems like you have created a leak somewhere.
  3. swissmade

    swissmade Active Member Licensed User

    I think I have found whats the problem.
    In the Module I had a timer and have not stop this when the socket is disconnected.
    The Timer is needed to update the time on the Web-page and to test some setting.
    If settings are changing the Web-page get updated.
    Every 1000ms.
    It seems, that this is still running in the Background.

    Is there an other way to run a timer in the WSmodule part without this problem??

    Now I have disable the Timer the Server is running well for the last hours.
    Memory about 35 mb and threads about 35-40.

    If you still like I can send the Project.
  4. Erel

    Erel Administrator Staff Member Licensed User

    Just make sure to disable the timer in the Disconnected event.
  5. swissmade

    swissmade Active Member Licensed User

    Have done this.
    Thanks Erel
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice