[Red5] Memory Leak in ClientRegistry with setId?

Kalr Mertens karl.mertens61 at web.de
Fri Jun 19 17:46:04 PDT 2009


Hell Thomas , here im my Post i relay on your last SourceCode... because i dident read all somehow 40 emails...

let me try this...


private final ConcurrentMap<String, ArrayList> userIDMap = new ConcurrentHashMap<Integer,  ArrayList>();//


  @Override
       public boolean appConnect(IConnection conn, Object[] params) 
{

               String myUserID = params[0].toString();
               conn.getClient().setId(myUserId); // one client different connection..where the dlient sets the Id... not very save:)
               ArrayList tempList;//here i would recomend to choose a linked list ... ArrayList are very slow when not attaching to the end of the list
               if (!userIDMap.containsKey(myUserID)) {
                             tempList =  userIDMap.get(myUserID);
               } else {
                              tempList = new ArrayList();  
               }
                tempList.add(conn);//save the Connection in the ArrayList
                userIDMap.put(myUserID, tempList);//save the ArrayList to the HachMap
    }

~~~~~~~~~~

 @Override
       public void appDisconnect(IConnection conn) 
      {
               String clientId = conn.getClient().getId();
               ArrayList<IConnection> cons = userIDMap.get(clientId);
               cons.remove(conn); //it must be inside else the client wouldent be connected and app DIsconnect is also then called when client pc hangs up or Browser crashes so i even dont check this
       }

~~~~~~~~~~

try this please  may change the variable names


about the other sourcecode:


while (i.hasNext())
                       {
                               rcon = i.next();
                               serviceCapCon = (IServiceCapableConnection) rcon;
                               serviceCapCon.invoke("intComm", sendobj);
                       }

do you realy whant to notify ALL CONNECTIONS for the desired clientId(sendTo) .. a second thing... inline code is faster than building the object to send first... i choose to have a function wherin i use inline code for the invoke but the call from anywhere in the application looks like "callClient(conn, arg1, arg2...);" much more handy and also fast.

greetz

btw. my current Project uses actual 7 concurrentHashMaps for mapping and as Spatial Memory for whereIn i save primitives and customObjects aswell and i dident see a bug at GC and dont see no leaks neither wether on RC2 i saw nor now on 0.8 final (!until yet!) 


What is the Ammount of conncurrent users and connections when you have these Leaks?





___________________________________________________________________
WEB.DE FreeDSL Komplettanschluss mit DSL 6.000 Flatrate und 
Telefonanschluss für 17,95 Euro/mtl.! http://produkte.web.de/go/02/




More information about the Red5 mailing list