# OutOfMemoryError

**URL:** <https://community.konduit.ai/t/outofmemoryerror/479>\
**Category:** ND4J\
**Created:** [May 4, 2020, 9:54am UTC](https://community.konduit.ai/t/outofmemoryerror/479 "2020-05-04T09:54:00Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![arnaud22](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/arnaud22/32/1405_2.png) [@arnaud22](https://community.konduit.ai/u/arnaud22)\
**Post date:** [May 4, 2020, 9:54am UTC](https://community.konduit.ai/t/outofmemoryerror/479/1 "2020-05-04T09:54:00Z")

</div>

Hi,

I get this eror during inference (prediction on 28\*28 pixels image):

 ![image](https://canada1.discourse-cdn.com/flex035/uploads/konduit/original/1X/8672cb5fc8a7ee600e1887e49ee381c452796070.png)

We launch few thread (8) and we do about 50 prediction per second / thread.

 ![image](https://canada1.discourse-cdn.com/flex035/uploads/konduit/original/1X/65ec5bdff4165642ad1fe40cdb232d96f79d5d0e.png)  
 ![image](https://canada1.discourse-cdn.com/flex035/uploads/konduit/original/1X/af06d8e8f724917485a634e9ef7ace144825a55a.png)

workspaces are enabled by default right ?  
I do not create INDArray elsewhere.

Some ideas what’s wrong ?  
Thx a lot.

---

<div class="post-metadata">

**Author:** ![treo](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/treo/32/47_2.png) [@treo](https://community.konduit.ai/u/treo)\
**Post date:** [May 4, 2020, 10:02am UTC](https://community.konduit.ai/t/outofmemoryerror/479/2 "2020-05-04T10:02:00Z")

</div>

Workspaces are used within training automatically. But when you use the model and return arrays outside of the framework’s control, there is nothing we can do for you automatically, so if you want to use workspaces here, you will need to do so manually.

---

<div class="post-metadata">

**Author:** ![arnaud22](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/arnaud22/32/1405_2.png) [@arnaud22](https://community.konduit.ai/u/arnaud22)\
**Post date:** [May 4, 2020, 10:45am UTC](https://community.konduit.ai/t/outofmemoryerror/479/3 "2020-05-04T10:45:18Z")

</div>

Do I have to use Workspace here ? I don’t see where i use arrays outside of framework’s control here 😕

---

<div class="post-metadata">

**Author:** ![treo](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/treo/32/47_2.png) [@treo](https://community.konduit.ai/u/treo)\
**Post date:** [May 4, 2020, 11:19am UTC](https://community.konduit.ai/t/outofmemoryerror/479/4 "2020-05-04T11:19:07Z")

</div>

@raver119 when arrays are used like this, outside of a workspace context, i.e. as autoclosables, will they be freed immediately?

---

<div class="post-metadata">

**Author:** ![raver119](https://avatars.discourse-cdn.com/v4/letter/r/9de053/32.png) [@raver119](https://community.konduit.ai/u/raver119)\
**Post date:** [May 4, 2020, 11:31am UTC](https://community.konduit.ai/t/outofmemoryerror/479/5 "2020-05-04T11:31:09Z")

</div>

Yes, they must be released immediately.

---

<div class="post-metadata">

**Author:** ![treo](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/treo/32/47_2.png) [@treo](https://community.konduit.ai/u/treo)\
**Post date:** [May 4, 2020, 12:34pm UTC](https://community.konduit.ai/t/outofmemoryerror/479/6 "2020-05-04T12:34:23Z")

</div>

In that case I’m not quite sure why it runs into an out of memory scenario.

The only thing I can see from your code is that you might want to use `muli` instead of `mul` to have that operation happen in place.

---

<div class="post-metadata">

**Author:** ![raver119](https://avatars.discourse-cdn.com/v4/letter/r/9de053/32.png) [@raver119](https://community.konduit.ai/u/raver119)\
**Post date:** [May 4, 2020, 12:36pm UTC](https://community.konduit.ai/t/outofmemoryerror/479/7 "2020-05-04T12:36:32Z")

</div>

@arnaud22 can you try snapshots please, and tell us if the problem is reproducible there as well?

---

<div class="post-metadata">

**Author:** ![arnaud22](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/arnaud22/32/1405_2.png) [@arnaud22](https://community.konduit.ai/u/arnaud22)\
**Post date:** [May 4, 2020, 12:41pm UTC](https://community.konduit.ai/t/outofmemoryerror/479/8 "2020-05-04T12:41:29Z")

</div>

@raver119 I’m on beta 6, you want i try with beta 7 ?

---

<div class="post-metadata">

**Author:** ![raver119](https://avatars.discourse-cdn.com/v4/letter/r/9de053/32.png) [@raver119](https://community.konduit.ai/u/raver119)\
**Post date:** [May 4, 2020, 12:44pm UTC](https://community.konduit.ai/t/outofmemoryerror/479/9 "2020-05-04T12:44:05Z")

</div>

Nope, 1.0.0-SNAPSHOT → [https://deeplearning4j.konduit.ai/config/config-snapshots](https://deeplearning4j.konduit.ai/config/config-snapshots)

---

<div class="post-metadata">

**Author:** ![arnaud22](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/arnaud22/32/1405_2.png) [@arnaud22](https://community.konduit.ai/u/arnaud22)\
**Post date:** [May 4, 2020, 1:02pm UTC](https://community.konduit.ai/t/outofmemoryerror/479/10 "2020-05-04T13:02:09Z")

</div>

I will try with muli

---

<div class="post-metadata">

**Author:** ![arnaud22](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/arnaud22/32/1405_2.png) [@arnaud22](https://community.konduit.ai/u/arnaud22)\
**Post date:** [May 4, 2020, 3:16pm UTC](https://community.konduit.ai/t/outofmemoryerror/479/11 "2020-05-04T15:16:02Z")

</div>

Apologize, the problem was corrected by increasing the memory allocated to the JVM …
