out-of-memory

OutOfMemory while setting image in ImageView

最后都变了- 提交于 2019-12-02 02:19:36
I am setting help screens images at 4 different places in my app. The activity code is the following- @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.help_list); int screenType = getIntent().getIntExtra("screenName", 0); ImageView imageView = (ImageView) findViewById(R.id.help_image); switch (screenType) { case 1: imageView.setImageResource(R.drawable.help0); break; case 2: imageView.setImageResource(R.drawable.help1); break; case 3: imageView.setImageResource(R.drawable.help2); break; case 4: imageView.setImageResource

Android java: OutOfMemory while inserting a huge List into the database SQL

守給你的承諾、 提交于 2019-12-02 01:44:45
I'm just working on an Android Project where an ORM greendao is used. It allows me to insert a number of entities (which are obviously objects) into the database at once (in one transaction). In practice there's a method insertOrReplaceInTx(...) which takes as a parameter a collection, given a List of objects. The problem is that my list has sort of 12000 objects and an insert leads from time to time to an OutOfMemory Exception. I'm thinking of a smart way to solve the problem and prevent future OOM. The only idea which comes to my mind is to split the huge collection into sort of

In XNA, what is the best method to dispose of textures I no longer need?

本小妞迷上赌 提交于 2019-12-01 23:32:00
I started a project with the concept of reusing the same texture2d objects continuously throughout the game, reloading new textures periodically. Over time this proved a bad idea as I was running in to: System.OutOfMemoryException bool loadImages(string image) { System.Diagnostics.Debug.WriteLine("beginning loading textures " + image); try { //image_a = null; //image_o = null; //image_o.Dispose(); //image_a.Dispose(); image_o = Content.Load<Texture2D>("images/"+image); image_a = Content.Load<Texture2D>("images/" + image+"_a"); return true; } catch { System.Diagnostics.Debug.WriteLine("cannot

How can I gracefully degrade my performance, given limited memory?

心不动则不痛 提交于 2019-12-01 22:05:21
问题 I've spent the last few days trying to remove memory leaks in my game, resulting in many out of memory errors. I'm on the verge of adding a significant amount of graphics, that while not hugely complicated, will add significantly to the processing requirements of my system, and I'm a bit worried about my memory usage, and I was hoping someone might have some tips for me. I don't want to go below Android 2.1, so please tailor any answers to that end. First of all, my game consists of: 2

OutOfMemoryException On Mobile Device

左心房为你撑大大i 提交于 2019-12-01 21:41:33
I'm developing an application that uses a mobile device to take a photo and send it using a webservice. But after I've taken 4 photos I am getting an OutOfMemoryException in the code below. I tried calling GC.Collect() but it didn't help either. Maybe someone here could be give me an advice how to handle this problem. public static Bitmap TakePicture() { var dialog = new CameraCaptureDialog { Resolution = new Size(1600, 1200), StillQuality = CameraCaptureStillQuality.Default }; dialog.ShowDialog(); // If the filename is empty the user took no picture if (string.IsNullOrEmpty(dialog.FileName))

Picasso gives out of memory when load an image

[亡魂溺海] 提交于 2019-12-01 21:29:15
I am using Picasso to load images from my server and display them in ImageView. I observes some crash reports from user's phone where Out of Memory Exception happens when Picasso is trying to load an image into ImageView. The stack trace as below: java.lang.OutOfMemoryError at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method) at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:596) at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:444) at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:832) at android.content.res

How can I gracefully degrade my performance, given limited memory?

落爺英雄遲暮 提交于 2019-12-01 19:52:41
I've spent the last few days trying to remove memory leaks in my game, resulting in many out of memory errors. I'm on the verge of adding a significant amount of graphics, that while not hugely complicated, will add significantly to the processing requirements of my system, and I'm a bit worried about my memory usage, and I was hoping someone might have some tips for me. I don't want to go below Android 2.1, so please tailor any answers to that end. First of all, my game consists of: 2 activities, 13 XML files (Some relating to a small part of a layout, some dialogs, and 2 directly related to

Upload files by post to server OutOfMemory

流过昼夜 提交于 2019-12-01 19:35:36
I'm developing a remote backup app, and Sometimes I need upload big files as for example 15 MB, I have tested in some phones I get an out of memory error Is there a way to use less memory using this function? public int uploadFile(String sourceFileUri) { String fileName = sourceFileUri; HttpURLConnection conn = null; DataOutputStream dos = null; String lineEnd = "\r\n"; String twoHyphens = "--"; String boundary = "*****"; int bytesRead, bytesAvailable, bufferSize; byte[] buffer; int maxBufferSize = 1 * 1024 * 1024; File sourceFile = new File(sourceFileUri); if (!sourceFile.isFile()) {

My Python for loop is causing a MemoryError. How can I optimize this?

怎甘沉沦 提交于 2019-12-01 19:34:24
问题 I'm trying to compile a list of all the MAC address Apple devices will have. oui.txt tells me Apple has been assigned 77 MAC ranges to use. These ranges come in the form of: 00:00:00 00:11:11 etc... This leaves me the last three HEX digits to append. That's 16^6 . A total of 1291845632 Apple MAC addresses. The problem I'm having is writing a program to create a list of these MAC addresses. Here's my current code: import re apple_mac_range = [] apple_macs = [] # Parse the HTML of http:/

WP8 Out of Memory error while loading Images

北城以北 提交于 2019-12-01 19:03:29
I am working on Windows Phone 8 app. I am working on Coverflow feature, i am trying to load 600 items but it always shows Out of Memory Error Code: <DataTemplate x:Key="DataTemplate1"> <Grid VerticalAlignment="Center" HorizontalAlignment="Center"> <Grid.RowDefinitions> <RowDefinition/> </Grid.RowDefinitions> <Border Grid.Row="0" Height="400" Width="400" CornerRadius="30,30,30,30"> <Border.Background> <ImageBrush ImageSource="Images/sample.png" /> </Border.Background> </Border> <Grid Grid.Row="0" HorizontalAlignment="Center" VerticalAlignment="Top"> <TextBlock HorizontalAlignment="Center"