Click here to Skip to main content
15,889,909 members
Home / Discussions / C#
   

C#

 
GeneralMessage Removed Pin
29-Aug-11 7:32
professionalN_tro_P29-Aug-11 7:32 
GeneralRe: 2D FFT / DFT + NxN Convolution (image processing) [modified] Pin
Dusan Paulovic29-Aug-11 8:57
Dusan Paulovic29-Aug-11 8:57 
AnswerRe: 2D FFT / DFT + NxN Convolution (image processing) Pin
Chris Losinger29-Aug-11 7:14
professionalChris Losinger29-Aug-11 7:14 
GeneralRe: 2D FFT / DFT + NxN Convolution (image processing) Pin
Dusan Paulovic29-Aug-11 8:59
Dusan Paulovic29-Aug-11 8:59 
GeneralRe: 2D FFT / DFT + NxN Convolution (image processing) Pin
Chris Losinger29-Aug-11 9:04
professionalChris Losinger29-Aug-11 9:04 
GeneralRe: 2D FFT / DFT + NxN Convolution (image processing) Pin
Dusan Paulovic29-Aug-11 9:28
Dusan Paulovic29-Aug-11 9:28 
GeneralRe: 2D FFT / DFT + NxN Convolution (image processing) Pin
Chris Losinger29-Aug-11 9:38
professionalChris Losinger29-Aug-11 9:38 
QuestionUnmanaged memory issue [modified] Pin
c4tchm4tt29-Aug-11 0:10
c4tchm4tt29-Aug-11 0:10 
HI all,

I've written an app that tries to have the main thread sleep while one or more (usually 2) threads idle in the background, each one waking up every X number of minutes to do a data transfer.

For some reason the Private bytes of the app are rising in small but constant increments each time each thread wakes up, and I can't see what I can do to make sure there's nothing hanging around in memory so that I can leave the programme unattended.

(I need to leave this program running on a live server for a long period, so proper use of disposal is really important.)

C#
        Main()
        {
            LaunchThreads(syncNodes); //Usually 2 XML nodes with some basic info like "period" and connection strings etc.
            //Thread.Sleep(-1); //With threads still alive I realised this line wasn't needed as the program will still be executing until all threads are dead (or if published as a task bar type windows app - the app is closed by the user)
        }

        static void LaunchThreads(XmlNodeList syncThreads)
        {
            foreach (XmlNode threadSetting in syncThreads)
            {
                Sync syncThread = new Sync(threadSettings);
                Thread t = new Thread(new ThreadStart(syncThread.Start));
                t.Start();
            }
        }
    }

    public class Sync
    {
        private XmlElement settings; //stores the info for the data transfer, period, connections etc.
        private int period;
        public Boolean interrupt

        public Sync(XmlElement syncSettings)
        {
            settings = syncSettings;
            interrupt = false;
            period = Convert.ToInt16(settings.GetAttribute("period").ToString())*60000;
        }

        public void Start()
        {
            while(!interrupt)
                {
                Execute();
            Thread.Sleep(period); 
                }
        }

        private void Execute()
        {
            //Do the data transfer using the "settings" XmlElement to define which database to connect to etc.
            //I have tried the code with and without the contents of this methods and the results in the private bytes are the same
        }
}


modified on Thursday, September 1, 2011 11:05 AM

AnswerRe: Unmanaged memory issue Pin
MicroVirus29-Aug-11 1:51
MicroVirus29-Aug-11 1:51 
GeneralRe: Unmanaged memory issue Pin
c4tchm4tt1-Sep-11 5:04
c4tchm4tt1-Sep-11 5:04 
GeneralRe: Unmanaged memory issue Pin
MicroVirus5-Sep-11 10:43
MicroVirus5-Sep-11 10:43 
AnswerRe: Unmanaged memory issue Pin
PIEBALDconsult30-Aug-11 7:48
mvePIEBALDconsult30-Aug-11 7:48 
GeneralRe: Unmanaged memory issue Pin
c4tchm4tt1-Sep-11 5:03
c4tchm4tt1-Sep-11 5:03 
GeneralRe: Unmanaged memory issue Pin
PIEBALDconsult1-Sep-11 14:53
mvePIEBALDconsult1-Sep-11 14:53 
Generalwindow application Pin
ashishchourey29-Aug-11 0:06
ashishchourey29-Aug-11 0:06 
GeneralRe: window application Pin
Blue_Boy29-Aug-11 0:31
Blue_Boy29-Aug-11 0:31 
GeneralRe: window application Pin
BillWoodruff29-Aug-11 0:59
professionalBillWoodruff29-Aug-11 0:59 
GeneralRe: window application Pin
Hari Om Prakash Sharma29-Aug-11 1:47
Hari Om Prakash Sharma29-Aug-11 1:47 
AnswerRe: window application Pin
Abhinav S29-Aug-11 1:49
Abhinav S29-Aug-11 1:49 
GeneralRe: window application PinPopular
Goutam Patra29-Aug-11 3:07
professionalGoutam Patra29-Aug-11 3:07 
Questionhow to connect to dbf database Pin
goldsoft28-Aug-11 22:19
goldsoft28-Aug-11 22:19 
AnswerRe: how to connect to dbf database Pin
Wayne Gaylard28-Aug-11 22:28
professionalWayne Gaylard28-Aug-11 22:28 
AnswerRe: how to connect to dbf database Pin
phil.o28-Aug-11 23:28
professionalphil.o28-Aug-11 23:28 
AnswerRe: how to connect to dbf database Pin
Eddy Vluggen29-Aug-11 0:28
professionalEddy Vluggen29-Aug-11 0:28 
AnswerRe: how to connect to dbf database Pin
V.29-Aug-11 3:32
professionalV.29-Aug-11 3:32 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.