| 177 | /// |
| 178 | /// - `java.io.IOException` |
| 179 | @SuppressWarnings("PMD.DoNotCallGarbageCollectionExplicitly") |
| 180 | public static Image createImage(String path) throws IOException { |
| 181 | try { |
| 182 | return new Image(Display.impl.createImage(path)); |
| 183 | } catch (OutOfMemoryError err) { |
| 184 | // Images have a major bug on many phones where they sometimes throw |
| 185 | // an OOM with no reason. A system.gc followed by the same call over |
| 186 | // solves the problem. This has something to do with the fact that |
| 187 | // there is no Image.dispose method in existance. |
| 188 | System.gc(); |
| 189 | System.gc(); |
| 190 | return new Image(Display.impl.createImage(path)); |
| 191 | } |
| 192 | } |
| 193 | |
| 194 | /// creates an image from the given native image (e.g. MIDP image object) |
| 195 | /// |