G
Guest
I'm doing a while true loop that never sets the boolean to false (ie I want
this program to run endlessly).
I've noticed after my thread sleeps for 30 seconds and wakes back up to
continue, the memory used by the system goes up by 4K.
Obviosly over days and weeks this will all mount up, so I really need to
understand about how to deal with garbage collection.
I null all my variables at the end of each loop and have created the
variables as private outside of the method I'm calling them in, in the main
class, but still the problem persists.
The code is rather long so I'd rather not post it in its entirety and have
to explain it all, but essentially the code goes:
while (true) {
checkThis();
thenCheckThis();
thenCheckThis();
Thread.sleep(30000);
}
all checkThis() does is:
{
go to a folder;
loops through folder;
anything with a certain file extension gets sent to another method;
}
That method just moves it the file from one place to another, deleting the
file from the original folder then thats it.
Why always 4K? Is this because java has a memory leak when running a loop,
or is it my code?
TIA for any pointers where to start looking!
this program to run endlessly).
I've noticed after my thread sleeps for 30 seconds and wakes back up to
continue, the memory used by the system goes up by 4K.
Obviosly over days and weeks this will all mount up, so I really need to
understand about how to deal with garbage collection.
I null all my variables at the end of each loop and have created the
variables as private outside of the method I'm calling them in, in the main
class, but still the problem persists.
The code is rather long so I'd rather not post it in its entirety and have
to explain it all, but essentially the code goes:
while (true) {
checkThis();
thenCheckThis();
thenCheckThis();
Thread.sleep(30000);
}
all checkThis() does is:
{
go to a folder;
loops through folder;
anything with a certain file extension gets sent to another method;
}
That method just moves it the file from one place to another, deleting the
file from the original folder then thats it.
Why always 4K? Is this because java has a memory leak when running a loop,
or is it my code?
TIA for any pointers where to start looking!