Time for action – finding the leak
It is necessary to know how many resources are allocated in order to know whether the leak has been plugged or not. Fortunately, SWT provides a mechanism to do this via the Display
and the DeviceData
class. Normally, this is done by a separate plug-in, but in this example, the ClockView
will be modified to show this behavior.
- At the start of the
ClockView
class'screatePartControl
method, add a call to obtain the number of allocated objects, via theDeviceData
of theDisplay
class:public void createPartControl(Composite parent) { Object[] objects = parent.getDisplay().getDeviceData().objects;
- Iterate through the allocated
objects
, counting how many are instances ofColor
:int count = 0; for (int i = 0; i < objects.length; ...
Get Eclipse Plug-in Development Beginner's Guide - Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.