How can I get the memory that my Java program uses via Java’s Runtime api?

There are similar questions out there, but they seem to avoid answering this specific question. How can I get the memory that my Java program uses via Java’s Runtime api? The answer here indicates that I can do something like this: System.out.println(“KB: ” + (double) (Runtime.getRuntime().totalMemory() – Runtime.getRuntime().freeMemory()) / 1024); But this always returns the … Read more

How to get around the memory leak in the .NET Webbrowser control?

This is a widely-known, old issue with the .NET Webbrowser control. Summary: Having the .NET webbrowser control Navigate to a page increases memory usage that is never freed. Reproduce the memory leak: Add a WebBrowser control to a form. Use it to Navigate to whatever pages you’d like. about:blank works, scrolling down on Google Images … Read more

Why memory functions such as memset, memchr… are in string.h, but not in stdlib.h with another mem functions?

I wonder, why such function as: -memset -memmov -memchr -memcpy Exist in string.h header file, but not in stdlib.h file, where there are other standard memory functions as dynamic memory allocation: malloc, calloc, realloc, free. Maybe it would be better to unite them in one header? What do you think about it? I don’t understand, … Read more

Eclipse memory settings when getting “Java Heap Space” and “Out of Memory”

When trying to launch and run a flex/java project in eclipse I kept getting a “Out of Memory Exception” and “Java Heap Space” using Eclipse, Tomcat and a JRE. While researching trying to adjust the memory settings I found three places to adjust these: Eclipse.ini The JRE Settings under Window > Preferences Catalina.sh or Catalina.bat … Read more

Is std::vector memory freed upon a clear?

Suppose I have a std::vector of structs. What happens to the memory if the vector is clear()’d? std::vector<myStruct> vecs; vecs.resize(10000); vecs.clear(); Will the memory be freed, or still attached to the vecs variable as a reusable buffer? Answer The memory remains attached to the vector. That isn’t just likely either. It’s required. In particular, if … Read more

C++11: Replace all non-owning raw pointers with std::shared_ptr()?

With the advent of std::unique_ptr, the blemished std::auto_ptr can finally be put to rest. So for the last several days, I have been changing my code to use smart pointers and to eliminate all delete from my code. Although valgrind says my code is memory-clean, the semantic richness of smart pointers will make for cleaner … Read more