This article is about a thorough understanding of how references work in Android and Java.
For an Android developer, if you don't use WeakReferences, this is a problem.
To give a proper example, a few months ago, I released my last book, "Android High Performance," by co-author Diego Gincini. One of the most popular chapters is to discuss memory management for Android. In this chapter, we describe how memory works in mobile devices, how memory leaks occur, why this is important, and what techniques we can apply to avoid them. Since I have been developing Android, I have often seen such a tendency to despise or even ignore all problems related to memory leaks and memory management. I have already met the development needs. Why do you have to be self-interested? We are always eager to develop new features, and we would rather present something visible in the next Sprint demo, and we won't care about things that no one can see at a glance.
This is undoubtedly a living example of technical debt. I can even add that technical debt has some impact in the real world, which we can't measure with unit tests: disappointment, friction between developers, low-quality software and loss of enthusiasm. The reason why this effect is difficult to measure is that they often occur at some point in the long-term future. This is a bit like a politician: If I am only in politics for 8 years, why should I worry about what will happen in 12 years? Except in software development, everything goes in a faster way.
Writing design ideas that should be adopted in software development may require some big articles, and there are already many books and articles for your reference. However, a brief explanation of the different types of memory references, what they are, and how to use them in Android is a relatively short task, which I want to do in this article.
First of all: What is the reference in Java?
A reference points to an object that you can access by reference.
Java has four types of references by default: StrongReference, SoftReference, WeakReference, and PhantomReference. Some people think that there are only two types of references, strong references and weak references, while weak references have two levels of weakening. We are used to categorizing everything in life, and that perseverance is comparable to that of botanists. No matter which classification you think is better, you first need to understand these references. Then you can find out your own classification.
What do the various references mean?
StrongReference: Strong references are the most common type of reference in Java. At any time, when we create an object, a strong reference is also created. For example, when we do this:
MyObject object = new MyObject();
A new MyObject object is created, and a strong reference to it is stored in object. Are you still watching? Well, the more interesting thing is that this object can be forcibly arrived - meaning that it can be found through a series of strong references, which will prevent the garbage collection mechanism from reclaiming it, however, this is exactly what we want most. of. Now let's look at an example.
Take a few minutes and try to find a point where problems may occur.
What now?
The AsyncTask object is created and run in the AcTIvity onCreate() method. But there is a problem here: the inner class will access the outer class throughout its life cycle.
What happens if AcTIvity is destroyed? AsyncTask still holds a reference to AcTIvity, so AcTIvity is not reclaimable by the GC. This is what we call a memory leak.
Side note: I used to interview the right people. I asked them how to create a memory leak instead of asking the theoretical aspects of memory leaks. This is always more fun!
Memory leaks actually happen not only when the activity itself is destroyed, but also when the system needs more memory when the configuration changes (translator's note: for example, the horizontal screen switches to vertical screen). If the AsyncTask is complex (for example, holding a reference to a View on an Activity), it can even cause a crash because the view's reference is null. (Translator's Note: This is a literal translation, may not be easy for some students. I give an example, such as AsyncTask reference ProgressDialog, AsyncTask will display ProgressDialog when running, when the horizontal screen is cut into vertical screen At this time, there will be a crash. (╯^╰>)
So how do you prevent this from happening again? We next introduce another type of reference:
PCB Material Fr4 Substrate PCB Board Manufacturing Service
As you know, the printed circuit board plays a vital role in electronic products, so you need to consider how to choose the right material in your PCB manufacturing. JHYPCB can offer you the lowest possible costs and the very finest in high-quality PCB fabrication and high-quality PCB assembly. However, there are many different types of PCB materials, such as FR-4 material, HDI material, Rogers PCB material, and so on. In general, we use the standard FR-4 material for the printed circuit boards to reduce product costs, which is a good option because FR-4 material is affordable and useful for many applications. However, FR-4 material is not the only type of PCB material; comparing to PCB material, FR-4 material, and Rogers material is essential.
What is FR4?
FR4 is a standard defined by the NEMA (National Electrical Manufacturers Association) for a glass-reinforced epoxy resin laminate.
"FR" indicates the material is flame-retardant, and the "4" indicates woven glass-reinforced epoxy resin. Single or double-sided PCB structures consist of an FR4 core and top and bottom copper layers. Multilayer PCB boards have additional prepreg layers between the center core and top and bottom copper layers. The core consists of a substrate with copper covering, also referred to as a copper-clad laminate(CCL). The core, laminate, and prepreg may all be FR4 with the copper sheets between the signal and ground layers. FR4 is the most common material grade that comprises fabricated circuit boards.
FR-4 or FR4`s properties and characteristics make it very versatile at an affordable cost. Before the explosion of multilayer PCBs, there were many alternative board materials to FR4. These included FR2, CEM 1, and CEM 3, which were paper-based. However, the strength of FR4, especially for multilayer PCB boards, was a significant factor in separating it from alternatives to become the industry standard. Therefore, Most PCBs are made using FR4 as the base material.
FR4 materials and characteristics
Its glass transition (TG) is 115°C to 200°C for the High TGs or HiTGs, depending on the manufacturing methods and the resins used. A standard FR-4 PCB will have a layer of FR-4 sandwiched between two thin layers of laminated copper.
FR-4 uses bromine, a so-called halogen chemical element that is fire resistant. It replaced G-10, another less resistant composite, in most of its applications.
FR4 has the advantage of having an excellent resistance-weight ratio. It does not absorb water, keeps high mechanical strength, and has an excellent insulating capacity in dry or humid environments.
Examples of FR-4
- Standard FR4: as its name indicates, this is the standard FR-4 with heat resistance of the order of 140°C to 150°C.
- High TG FR4: this type of FR-4 has higher glass transition (TG) of around 180°C.
- High CTI FR4: Comparative Tracking Index higher than 600 Volts.
- FR4 with no laminated copper: ideal for insulation plates and board supports.
- There are more details of the characteristics of these different materials later in the article.
Factors to consider when choosing the thickness
- Compatibility with components: even though FR-4 is used to produce many types of the printed circuit, its thickness affects its components. For example, THT components are different from other components and require a thin PCB.
- Space-saving: space saving is essential when designing a PCB, particularly for USB connectors and Bluetooth accessories. The thinnest boards are used in configurations in which space-saving is crucial.
- Design and flexibility: most manufacturers prefer thick boards to thin ones. Using FR-4, if the substrate is too thin, it would be at risk of breaking if the board dimensions were increased. On the other hand, thicker boards are flexible and make it possible to create V-grooves.
- The environment in the PCB that will be used must be considered. For an electronic control unit in the medical field, thin PCBs guarantee reduced stress. Boards that are too thin - and therefore too flexible - are more vulnerable to heat. They can bend and take on an undesirable angle during the component soldering steps.
- Impedance control: the board thickness implies the dielectric environment consistency, in this case, FR-4, which facilitates impedance control. When impedance is an essential factor, the board thickness is a determining criterion to be taken into account.
- Connections: the type of connectors used for a printed circuit also determines the FR-4 thickness.
The Different Types of FR-4 Available From JHYPCB
JHYPCB STANDARD FR-4 MATERIAL PROPERTIES
- High Glass Transition Temperature (Tg) (150Tg or 170Tg)
- High Decomposition Temperature (Td) (> 345º C)
- Low Coefficient of Thermal Expansion (CTE) ((2.5%-3.8%)
- Dielectric Constant (@1 GHz): 4.25-4.55
- Dissipation Factor (@ 1 GHz): 0.016
- UL rated (94V-0, CTI = 3 minimum)
- Compatible with standard and lead-free assembly.
- Laminate thickness available from 0.005" to 0.125"
- Pre-preg thicknesses available (approximate after lamination):
- (1080 glass style) 0.0022"
- (2116 glass style) 0.0042"
- (7628 glass style) 0.0075"
Standard FR4
- FR4 SHENGYI family S1000H
- Thickness from 0.2 to 3.2 mm.
- FR4 VENTEC family VT 481
- Thickness from 0.2 to 3.2 mm.
FR4 High TG
- FR4 SHENGYI family S1000-2
- Thickness from 0.6 to 3.2 mm.
- FR4 VENTEC family VT 47
- Thickness from 0.6 to 3.2 mm.
FR4 High IRC
- FR4 SHENGYI family S1600
- Standard thickness 1.6 mm.
- FR4 VENTEC family VT 42C
- Standard thickness 1.6 mm.
FR4 with no copper
- This material is an epoxy glass with no copper, designed for use in insulation plates, templates, board supports, etc. They are manufactured using Gerber type mechanical drawings or DXF files.
- Thickness from 0.3 to 5 mm.
The Difference Between FR-4 Material and Rogers Material
1. FR-4 material is cheaper than Rogers material.
2. Comparing to FR-4 material, Rogers material is great with high frequencies.
3. FR-4 material has a high Df or dissipation factor than Rogers material, suffering more signal loss.
4. In impedance stability, Rogers material has a wider range of Dk values than FR-4 material.
5. For dielectric constant, FR-4 features a Dk of about 4.5, which is lower than Rogers material with around 6.15 to 11.
6. In temperature management, Rogers material has a less variation comparing to FR-4 material.
When is FR4 Not the Best Material For Your Board?
FR4 is indeed a good standard or default option for your board material in most cases. However, there are cases where FR4 is not the best material for your board, as listed below.
- If lead-free soldering is required
If your boards will be distributed in Europe and must adhere to The Restriction of Hazardous Substances Directive (RoHS) or your client necessitates that lead-free soldering be used, then you may want to explore other material options. This is due to the fact that reflow temperatures for no-lead PCBA(Lead-free PCB Assembly) may reach as high as 250°C, which substantially exceeds the Tg for many versions of FR4.
- If high-frequency signals are used
At high frequencies, FR4 boards are not able to maintain a constant impedance and reflections may occur that negatively impact signal integrity. This is a consequence of the relatively high value for dk.
- If the board will be exposed to extremely high temperatures during operation
It is also ill-advised to use FR4 if the PCB will be required to operate in an environment under extremely high temperatures. An example would be near the engine compartment of an aerospace vehicle.
FR4 is rightly the most used material in PCB construction. Boards made from FR4 are strong, water resistant, and provide good insulation between copper layers that minimizes interference and supports good signal integrity. However, at high frequencies and in environments, FR4 is not the best material to use for your boards. At JHYPCB, the industry leader in fast, high-quality PCB Prototype and low-volume manufacturing, we are capable to meet your board material needs for any case. We will work with you to help you select the materials that will best implement your design intent.
And to help you get started on the best path, we furnish information for your DFM checks. If you are ready to have your design manufactured, Try to contact us via email.
Fr4 PCB, Fr-4 Substrate PCB, PCB Material Fr4, Fr4 PCB Material
JingHongYi PCB (HK) Co., Limited , https://www.pcbjhy.com