I want to use IDisposable interface to clean any resource from the memory, that is not being used.
public class dispose:IDisposable
{
public void Dispose()
{
throw new NotImplementedException();
}
public void fun()
{
PizzaFactory _pz = new PizzaFactory(); //
}
...
I have been reading these slides about Java finalizers. In it, the author describes a scenario (on slide 33) whereby CleanResource.finalize() could be run by the finalizer thread while CleanResource.doSomething() is still running on another thread. How could this happen?
If doSomething() is a non-static method, then to execute that me...
In my DAL I write queries like this:
using(SQLConnection conn = "connection string here")
{
SQLCommand cmd = new ("sql query", conn);
// execute it blah blah
}
Now it just occurred to me that I am not explicitly closing the SQLCommand object. Now I know the 'using' block will take care of the SQLConnection object, but will thi...
How to call finalize method in Obj-c for garbage collection?
...
I'm really looking for some best practice wisdom. So here are the questions, I'll add more if people leave comments. Feel free to answer some or all of these questions.
When SHOULD I use IDisposable? Only when I have unmanaged resources?
What variations of the dispose pattern are there and why do they vary?
What are common unmanaged ...
Hello all,
I have the function below which I call very frequently in a loop.
I waited 5 minutes as the memory climbed up from 1MB to 156MB. Should't PHP's garabage collector turn up and reduce this at some point?!
Is it because I have set memory limit at 256MB?
At echo point 2,3,4 its pretty constant memory usage. It goes down my hal...
How well optimized is Java's parallel collecting GC for multithreaded environments? I've written some multithreaded Jython code that spends most of its time calling Java libraries. Depending on which options I run the program with, the library calls either do tons of allocations under the hood or virtually none. When I use the options...
I am currently debugging a web application which has been causing intermittent problems especially when the hit rate is high. As each new user is given a session containing personalised navigation menu I thought I would try to see how much memory the session variables need.
In a code section of the JSP which handles the creation of sess...
It was a very fast and makeshift, bug fix..
It worked, but I would like to find a better understanding and solution.
This was the Class Constructor generating the leak
final transient DataInputStream din;
final transient DataOutputStream dout;
final transient BufferedReader bin;
final transient BufferedWriter bout;
NData(Socket s...
Is it possible to configure web.xml to reload a specific tomcat webapp at a particular time automatically. If not, is it possible to do this programatically?
...
Hi,
This might be pretty basic, but was very curious to know.
Here's the code snippet and the output
public class PlainSystemGC {
public static void main(String ...strings) {
System.out.println("Free Memory (Before GC): " + Runtime.getRuntime().freeMemory());
System.gc();
System.out.println("Free Memor...
I have a java applet that loads up a scroll view that you can add several thousand views to, everything works fine. If I close that browser window and open a new window and view my applet again and start adding views it eventually runs out of memory. It seems like garbage collection didn't occur when I closed the window before:
a: why...
I am not sure how the user defined class objects are garbage collected. Do I need to implement IDisposable interface on every class and call the dispose() method on it to free the memory?
...
Hi all,
I am trying to adapt the underlying structure of plotting code (matplotlib) that is updated on a timer to go from using Python lists for the plot data to using numpy arrays. I want to be able to lower the time step for the plot as much as possible, and since the data may get up into the thousands of points, I start to lose valua...
Hi,
Have a question about Sun GC. The Sun FAQ (old one for 1.4.2) says that the throughput collector does not use the MaxTenuringThreshold (MTT) parameter. Its used only for CMS.
http://java.sun.com/docs/hotspot/gc1.4.2/faq.html
I dont know how to verify this, but if its true, how does the throughput collector determine when to promote...
I am experiencing problem in my application with OutOfMemoryException. My application can search for words within texts. When I start a long running process search to search about 2000 different texts for about 2175 different words the application will terminate at about 50 % through with a OutOfMemoryException (after about 6 hours of pr...
Here's an interesting article that I found on the web.
It talks about how this firm is able to parse a huge amount of financial data in a managed environment, essentially by object reuse and avoiding immutables such as string. They then go on and show that their program doesn't do any GC during the continuous operation phase.
This is p...
I'm trying to optimize memory usage of a program and therefore wants to remove objects when they aren't needed any longer. To check if this works correctly I wrote a console.writeline method in the destructor of the type of object I want to remove. However when I test the program, no lines are written (only when the program terminates of...
I've read about the different kinds of GC and how they work. All involve traversing the set of memory which might potentially be reclaimed, but nothing I've read gives any indication as to how this is actually done. Would something like the following be way off the mark?
void* myAlloc(size_t size)
{
if (needToGc())
gc();
...
I'm really bothered by having to nest using blocks in C#. It's not elegant and it takes up a lot of space. In some cases it appears to be unavoidable because I need to declare variables of different data types, but it seems like the single-type case should be possible to simplify. What I mean by "the single-type case" is when several var...