Say No to “Memory Leakage”
As you’ll start working with Java programming language, you will learn that it offers a unique feature for managing memory automatically and that’s where the downfall of this feature relies. When we say automatic memory management, that doesn’t mean that you will avoid checking memory manually. That’s why, In order to survive any unavoidable memory leakage, developers should have the presence of mind to check on their project where they are writing the code to ensure that they are not leaving any stone unturned that leads to hampering performance degradation.
For reference, have a look at the example below that might cause a memory leakage: static field
Java
private Random random = new Random(); public static final ArrayList<Double> list = new ArrayList<Double>( 1000000 ); @Test public void checkMemoryLeak() throws InterruptedException { for ( int k = 0 ; k < 1000000 ; k++) { list.add(random.nextDouble()); } System.gc(); // Allow GC do its Job Thread.sleep( 10000 ); } |
*Note: Here, ArrayList is a static field that will never be created by JVM Garbage Collector.
If you want to learn Java and looking for some complete Java Courses then w3wiki is here to help you. Refer to the below-mentioned links:
10 Most Common Mistakes That Java Developers Make
If you’re working on any new programming language, there might be certain phases where you can get stuck. This eventually leads any developer to make minor-major errors and creates a roadblock towards their learning curve. Not to forget, as much as you’ll be making mistakes, you’ll achieve excellence. Besides this, learning Java is no different task and thus it can also be excelled with time and with the right resources (tutorials, courses, books, etc) but the path towards becoming an expert is not as simple as it sounds, you need to ensure that you’re avoiding all the “Basic” mistakes that most developers do when they’re at “Beginner” level.
No matter how better a programmer you are, it is always necessary to make some mistakes, and the best part is it’s good to be informed about the blunders that you’re doing and avoid making such errors while coding. That’s why we came up with this article to highlight the 10 most common mistakes that every developer makes during their coding life and it might give you some clarity on how to avoid those mistakes. So, let’s check them out one-by-one.