memory management - Separate one process into several processes in C# -
i have function setcamerachannel open camera channel based on device data in database. tested open 5 channels , works fine (around 400,000k memory though), if open 20 channels, lead "failed allocate memory".
is possible separate 20 channels 4 different processes (1 process contains 5 channels) , when channel cannot opened, automatically trying re-open channel?
or have idea how run 20 channels without having memory allocation problem?
private void setcamerachannel() { system.threading.threadpool.queueuserworkitem(new system.threading.waitcallback(delegate(object state) { foreach (datarow dr in dtfdinfo.rows) { fdcamera fdcamerachannel = null; url = string.format("rtsp://{0}:{1}@{2}:{3}/live/video/h264/record/ch{4}?tcp", dr["sourceuserid"], dr["sourceuserpw"], dr["sourceip"], getchannelport(dr), getdevicechnum(dr)); if (fdcamerachannel != null) { fdcamerachannel.dispose(); } fdcamerachannel = new fdcamera(dr["device_name"].tostring(), url, dr); } })); }
you can create named process dynamically c# using assemblybuilder , typebuilder classes , create channels required inside each processes, memory allocation split across different process , can managed properly.
Comments
Post a Comment