out-of-memory

How to avoid java.lang.OutOfMemoryError?

只愿长相守 提交于 2019-12-02 13:08:54
问题 I have two simple java codes.The first one defines constant power as power = a.pow(b); import java.math.BigInteger; public class FermatOne { public static void main(String[] args) { BigInteger a = new BigInteger ("2"); BigInteger k = new BigInteger ("15"); BigInteger c = new BigInteger ("1"); int b = 332192810; BigInteger n = new BigInteger ("2"); BigInteger power; power = a.pow(b); BigInteger exponent; exponent = k.multiply(power); BigInteger mod; mod = exponent.add(c); BigInteger result = n

Why do files remain in project window after being closed?

谁说胖子不能爱 提交于 2019-12-02 13:00:40
Scenario I have a userform, and when a button is pressed, it opens an Excel file as read-only, gets some values, and closes that file. Following are the codes I am using to open and close the file. To open: Set planbook = Workbooks.Open(planFilePath, ReadOnly:=True) To close: planbook.Close False Problem After closing the file, I see that file in the project window, for each time I press the button. It is using a lot of memory. Due to this, Excel hangs intermittently. Why are files opened earlier but currently closed still appearing in the project window? Note, when the button is pressed three

java.lang.OutOfMemoryError while converting over 100 Strings into to byte arrays

大兔子大兔子 提交于 2019-12-02 11:55:40
Firstly, I understand questions regarding java.lang.OutOfMemoryError and Bitmaps have already been asked numerous times before. I have also checked out the Displaying Bitmaps Efficiently page. My use case: I am storing two different sized Bitmaps as Strings in an SQLite database. The first size of the Bitmaps is 50% of the screen width, and the second size is 100% of the screen width. I am using a RecyclerView which displays the images in ImageViews which are either 50% or 100% of the screen width, so the Bitmaps being loaded are no bigger than they need to be, and they are appropriately sized

java stackoverflowerror thrown in infinite loop

不问归期 提交于 2019-12-02 11:53:43
I have the following function that starts a jsvc daemon for receiving UDP messages: @Override public void start() throws Exception { byte[] buf = new byte[1000]; DatagramPacket dgp = new DatagramPacket(buf, buf.length); DatagramSocket sk; sk = new DatagramSocket(1000); sk.setSoTimeout(0); byte[] rcvMsg = null; run(sk, dgp, rcvMsg); } With a timeout of 0, the socket blocks until a another message comes in. This is what triggers the continuous run through the following while loop: MessageConstructor tmc =null; Message message = null; public void run(DatagramSocket sk, DatagramPacket dgp, byte[]

Out of Memory Exception when using File Stream Write Byte to Output Progress Through the Console

不想你离开。 提交于 2019-12-02 11:02:55
问题 I have the following code that throws an out of memory exception when writing large files. Is there something I'm missing? I am not sure why it is throwing an out of memory error as I thought the Filestream would only use a maximum of 4096 bytes for the buffer? I am not entirely sure what it means by the Buffer to be honest and any advice would be appreciated. public static async Task CreateRandomFile(string pathway, int size, IProgress<int> prog) { byte[] fileSize = new byte[size]; new

junitreport ant task giving java.lang.OutOfMemoryError: Java heap space

拥有回忆 提交于 2019-12-02 10:33:10
问题 I'm running junit tests from an ant script. The tests run successfully so ant moves on to the the junitreport task to create the html report. This task is failing with a java.lang.OutOfMemoryError: Java heap space error . How can I increase the heap size for this task? Or is there another way to resolve this error? Some additional information: It was working fine until I added 40 additional tests I've had a look at the xml output of the tests and it looks reasonable i.e. it's not full of long

OutOfMemoryError when hot-deploying SpringMVC app to Tomcat7 - possible relation to log4j2

余生长醉 提交于 2019-12-02 10:03:05
I am having trouble Hot Deploying a Spring-MVC 4.0 (not SpringBoot) Web Application. I am trying to go xml-less and just use JavaConfig. OutOfMemoryErrors result when I remove web.xml , or when I deploy an empty web.xml with nothing but an empty element . This does not happen every time the app is hot-deployed, and after a successful hot-deployment, the app does work correctly, but after three or four hot-deployments with this configuration the following error occurs: Jul 03, 2015 10:49:43 AM org.springframework.web.context.ContextLoader initWebApplicationContext SEVERE: Context initialization

OutofMemoryError ImageView

a 夏天 提交于 2019-12-02 10:02:52
I have a problem with imageview, i have 77 picture jpg and have 126 quote text, just simple app i want is i want show all quote with background picture and i use viewflipper so when i swipe left/right get into next quote. I give you my code that i use now. Hope that anyone can help me.. Really wasting my time to fix it. My picture : 320x480. vf = (ViewFlipper) findViewById(R.id.pages); for (i = 0; i<totalphrase;i++) { Log.i("ID",""+i); var = arrayphrase.get(i); //iv.setBackgroundColor(Color.rgb((int)Math.ceil(Math.random()*100), (int)Math.ceil(Math.random()*100), (int)Math.ceil(Math.random()

OutOfMemory exception in a lot of memory

耗尽温柔 提交于 2019-12-02 10:02:47
Sorry for the bad question name but i couldn't find anything better. I have some code long heapFreeSize = Runtime.getRuntime().freeMemory(); URL url = new URL("http://example.com"); URLConnection myUrlConnection = url.openConnection(); GZIPInputStream gZIPInputStream = new GZIPInputStream(myUrlConnection.getInputStream()); StringBuffer decompressedStringBuffer = new StringBuffer(); int bytes_read; int bufferSize; heapFreeSize = Runtime.getRuntime().freeMemory(); while ((bytes_read = gZIPInputStream.read(buffer)) > 0) { String part = new String(buffer, 0 ,bytes_read, "UTF-8"); heapFreeSize =

Upload file in Android with outofmemory error

别等时光非礼了梦想. 提交于 2019-12-02 10:02:30
My upload code as below: String end = "\r\n"; String twoHyphens = "--"; String boundary = "*****"; try { URL url = new URL(ActionUrl); HttpURLConnection con = (HttpURLConnection) url.openConnection(); con.setDoInput(true); con.setDoOutput(true); con.setUseCaches(false); con.setRequestMethod("POST"); con.setRequestProperty("Connection", "Keep-Alive"); con.setRequestProperty("Accept", "text/*"); con.setRequestProperty("Content-Type", "multipart/form-data; boundary=" + boundary); DataOutputStream ds = new DataOutputStream(con.getOutputStream()); ds.writeBytes(twoHyphens + boundary + end); ds