Bibek Kr. Bazaz
Bibek Kr. Bazaz

Reputation: 545

Mule 4 : Memory Management : Can stackoverflowerror occur in mule if the argument passed is too big in size?

I have the following understanding in Dataweave/Java

local variable for a method are stored in stack memory, and if methods are using objects as local variable, then the object is created in heap memory and the local variable will have a reference to that particular object created in Heap Memory.

If that is correct, can we face stackoverflow error in Mule if we use dataweave methods like join or reduce to process a parameter which is an Array of objects having size more than 50k?

<ee:transform doc:name="Outer Join And Merge" doc:id="fd801b56-9992-4a89-95a3-62ab4c4dc5a2">
<ee:message>
<ee:set-payload>%dw 2.0
import * from dw::core::Arrays
output application/java
var joinedData = outerJoin(vars.databaseOneRecords,vars.databaseTwoRecords,(obj)->obj.StudentID,(obj)->obj.RollNumber)
---
joinedData reduce ((item, acc = {
    'matched': [],
    'unmatched': []
})      
                            ->  if(item.l != null and item.r != null)
                                    {
    matched: (acc.matched default []) ++ [item.l ++ item.r],
    unmatched: acc.unmatched
}  
                                    else {
    matched: acc.matched,
    unmatched: (acc.unmatched default []) ++ [ if(item.l != null) item.l else item.r ]
} )</ee:set-payload>
</ee:message>
</ee:transform>



Sample data can be :

databaseOneRecords
[
{StudentName:ABC, StudentID:011,StudentClass:Fifth_Standard},
{StudentName:BAS, StudentID:012,StudentClass:Fifth_Standard},
{StudentName:WSA, StudentID:013,StudentClass:Fifth_Standard},
{StudentName:WSE, StudentID:014,StudentClass:Fifth_Standard},
{StudentName:DDD, StudentID:015,StudentClass:Fifth_Standard},
{StudentName:bgg, StudentID:016,StudentClass:Fifth_Standard},
{StudentName:hhh, StudentID:017,StudentClass:Fifth_Standard},
{StudentName:vvf, StudentID:019,StudentClass:Fifth_Standard},
{StudentName:vvv, StudentID:018,StudentClass:Fifth_Standard},
{StudentName:rrr, StudentID:020,StudentClass:Fifth_Standard}
]
databaseTwoRecords
[
{StudentName:ABC, RollNumber:011,Hobby:Cricket},
{StudentName:BAS, RollNumber:012,Hobby:Cricket},
{StudentName:WSA, RollNumber:013,Hobby:Cricket},
{StudentName:WSE, RollNumber:014,Hobby:Cricket},
{StudentName:DDD, RollNumber:015,Hobby:Cricket},
{StudentName:bgg, RollNumber:016,Hobby:Cricket},
{StudentName:hhh, RollNumber:017,Hobby:Cricket},
{StudentName:vvf, RollNumber:019,Hobby:Cricket},
{StudentName:vvv, RollNumber:018,Hobby:Cricket},
{StudentName:rrr, RollNumber:020,Hobby:Cricket}
]

Upvotes: 0

Views: 207

Answers (1)

machaval
machaval

Reputation: 5059

Reduce is iterative so you should not run with stackoverflow you may run out of memory but not stack. That may happen if there is some recursive function then yes. If it is happening to you please post your script with some sample data and we can work from that.

Upvotes: 1

Related Questions