Android内存不足

时间:2017-01-03 19:52:00

标签: android android-studio android-memory

我有一个奇怪的内存不足问题,我无法解决。我相信我可能在websocket处理方面有问题,但我不确定为什么或在哪里。我曾尝试使用Android Monitor进行内存转储,但我似乎无法解决问题。我尝试添加android:largeHeap =“true”flag。

我不知道从那里去哪里以及如何解决这个问题或检查什么。你对我能做什么有什么建议吗?我使用firebase进行生产错误记录,在发生错误时我也会收到此错误堆栈:

Exception java.lang.OutOfMemoryError: Failed to allocate a 916 byte allocation with 8388608 free bytes and 369MB until OOM; failed due to fragmentation (required continguous free 65536 bytes for a new buffer where largest contiguous free 32768 bytes)
java.nio.CharBuffer.allocate (CharBuffer.java:54)
java.nio.charset.CharsetDecoder.allocateMore (CharsetDecoder.java:226)
java.nio.charset.CharsetDecoder.decode (CharsetDecoder.java:188)
org.java_websocket.util.Charsetfunctions.stringUtf8 (Charsetfunctions.java:77)
org.java_websocket.WebSocketImpl.decodeFrames (WebSocketImpl.java:375)
org.java_websocket.WebSocketImpl.decode (WebSocketImpl.java:158)
org.java_websocket.client.WebSocketClient.run (WebSocketClient.java:185)
java.lang.Thread.run (Thread.java:818)

我理解这个问题很模糊,但我很感激建议下一步该去哪里。

1 个答案:

答案 0 :(得分:0)

尝试在清单中添加这些行

Traceback (most recent call last):
  File "C:\Users\M99E374\AppData\Local\Continuum\Anaconda3\lib\site-packages\tensorflow\python\client\session.py", line 1021, in _do_call
return fn(*args)
  File "C:\Users\M99E374\AppData\Local\Continuum\Anaconda3\lib\site-packages\tensorflow\python\client\session.py", line 1003, in _run_fn
status, run_metadata)
  File "C:\Users\M99E374\AppData\Local\Continuum\Anaconda3\lib\contextlib.py", line 66, in __exit__
next(self.gen)
  File "C:\Users\M99E374\AppData\Local\Continuum\Anaconda3\lib\site-packages\tensorflow\python\framework\errors_impl.py", line 469, in raise_exception_on_not_ok_status
pywrap_tensorflow.TF_GetCode(status))
tensorflow.python.framework.errors_impl.OutOfRangeError: RandomShuffleQueue '_1_shuffle_batch/random_shuffle_queue' is closed and has insufficient elements (requested 100, current size 49)
 [[Node: shuffle_batch = QueueDequeueMany[_class=["loc:@shuffle_batch/random_shuffle_queue"], component_types=[DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_STRING], timeout_ms=-1, _device="/job:localhost/replica:0/task:0/cpu:0"](shuffle_batch/random_shuffle_queue, shuffle_batch/n)]]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:/Users/M99E374/Projects/Training/tensorflowbook-master/tensorflowbook-master/chapters/04_machine_learning_basics/softmax.py", line 93, in <module>
print("loss: ", sess.run([total_loss]))
  File "C:\Users\M99E374\AppData\Local\Continuum\Anaconda3\lib\site-packages\tensorflow\python\client\session.py", line 766, in run
run_metadata_ptr)
  File "C:\Users\M99E374\AppData\Local\Continuum\Anaconda3\lib\site-packages\tensorflow\python\client\session.py", line 964, in _run
feed_dict_string, options, run_metadata)
  File "C:\Users\M99E374\AppData\Local\Continuum\Anaconda3\lib\site-packages\tensorflow\python\client\session.py", line 1014, in _do_run
target_list, options, run_metadata)
  File "C:\Users\M99E374\AppData\Local\Continuum\Anaconda3\lib\site-packages\tensorflow\python\client\session.py", line 1034, in _do_call
raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.OutOfRangeError: RandomShuffleQueue '_1_shuffle_batch/random_shuffle_queue' is closed and has insufficient elements (requested 100, current size 49)
 [[Node: shuffle_batch = QueueDequeueMany[_class=["loc:@shuffle_batch/random_shuffle_queue"], component_types=[DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_STRING], timeout_ms=-1, _device="/job:localhost/replica:0/task:0/cpu:0"](shuffle_batch/random_shuffle_queue, shuffle_batch/n)]]

Caused by op 'shuffle_batch', defined at:
  File "C:/Users/M99E374/Projects/Training/tensorflowbook-master/tensorflowbook-master/chapters/04_machine_learning_basics/softmax.py", line 79, in <module>
X, Y = inputs()
  File "C:/Users/M99E374/Projects/Training/tensorflowbook-master/tensorflowbook-master/chapters/04_machine_learning_basics/softmax.py", line 46, in inputs
read_csv(100, "iris.data", [[0.0], [0.0], [0.0], [0.0], [""]])
  File "C:/Users/M99E374/Projects/Training/tensorflowbook-master/tensorflowbook-master/chapters/04_machine_learning_basics/softmax.py", line 40, in read_csv
min_after_dequeue=batch_size)
  File "C:\Users\M99E374\AppData\Local\Continuum\Anaconda3\lib\site-packages\tensorflow\python\training\input.py", line 917, in shuffle_batch
dequeued = queue.dequeue_many(batch_size, name=name)
  File "C:\Users\M99E374\AppData\Local\Continuum\Anaconda3\lib\site-packages\tensorflow\python\ops\data_flow_ops.py", line 458, in dequeue_many
self._queue_ref, n=n, component_types=self._dtypes, name=name)
  File "C:\Users\M99E374\AppData\Local\Continuum\Anaconda3\lib\site-packages\tensorflow\python\ops\gen_data_flow_ops.py", line 1099, in _queue_dequeue_many
timeout_ms=timeout_ms, name=name)
  File "C:\Users\M99E374\AppData\Local\Continuum\Anaconda3\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 759, in apply_op
op_def=op_def)
  File "C:\Users\M99E374\AppData\Local\Continuum\Anaconda3\lib\site-packages\tensorflow\python\framework\ops.py", line 2240, in create_op
original_op=self._default_original_op, op_def=op_def)
  File "C:\Users\M99E374\AppData\Local\Continuum\Anaconda3\lib\site-packages\tensorflow\python\framework\ops.py", line 1128, in __init__
self._traceback = _extract_stack()

OutOfRangeError (see above for traceback): RandomShuffleQueue '_1_shuffle_batch/random_shuffle_queue' is closed and has insufficient elements (requested 100, current size 49)
 [[Node: shuffle_batch = QueueDequeueMany[_class=["loc:@shuffle_batch/random_shuffle_queue"], component_types=[DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_STRING], timeout_ms=-1, _device="/job:localhost/replica:0/task:0/cpu:0"](shuffle_batch/random_shuffle_queue, shuffle_batch/n)]]

它适用于某些情况。