Ok. Good to know, although bit depressing if Android really has such strict
limitations. Jackson-jr should keep less state information so it could
help, but I can't say how big the difference is a priori.

-+ Tatu +-

On Thu, Jul 21, 2016 at 4:35 PM, Colin White <[email protected]> wrote:

> Unfortunately, it doesn't seem like there's an easy way to track
> allocations on the stack on Android that I could find. For any future users
> the way I solved my problem was to simply create a thread with a larger
> stack (1MB was more than enough). See here
> <https://developer.android.com/reference/java/lang/Thread.html#Thread(java.lang.ThreadGroup,%20java.lang.Runnable,%20java.lang.String,%20long)>
> .
>
> I'm not 100% sure, but it seems like Jackson is working as intended and
> Dalvik just has a very restrictive call stack size. I've attached my stack
> trace and it shows that each nested JSON node adds 8 method calls to the
> stack, though I'm not sure how much state is being stored at each step. I
> upgraded to Jackson 2.8.1 and it still has the same behaviour.
>
> On Wednesday, 6 July 2016 10:10:38 UTC-7, Tatu Saloranta wrote:
>>
>> Thank you!
>>
>> -+ Tatu +-
>>
>> On Fri, Jul 1, 2016 at 10:05 AM, Colin White <[email protected]> wrote:
>>
>>> Thanks for the response. I'll take a closer look into the allocations on
>>> the stack and report back.
>>>
>>> -Colin
>>>
>>>
>>> On Thursday, 30 June 2016 22:33:41 UTC-7, Tatu Saloranta wrote:
>>>>
>>>> 50 levels it not a lot, but at the same time, amount of state Jackson
>>>> keeps should not be big so it is bit puzzling. 32kb/50 gives about 600
>>>> bytes and I wouldn't think there is that much state kept per level.
>>>> Generator keeps couple of things (property name, index number, parent
>>>> reference), serializers also but it really should not add up to anything
>>>> significant.
>>>>
>>>> Jackson-jr is very minimalistic so if this really is proportional to
>>>> state it should fare bit better (generator is the same). Perhaps worth
>>>> testing. Maybe write a simple test to see.
>>>>
>>>> But all in all it seems odd; unfortunately I don't know what could
>>>> cause it.
>>>>
>>>> -+ Tatu -
>>>>
>>>>
>>>> On Thu, Jun 30, 2016 at 12:28 PM, Colin White <[email protected]>
>>>> wrote:
>>>>
>>>>> I'm trying to serialize a JSON object that represents a conversation
>>>>> tree. Here's the POJO:
>>>>>
>>>>> class Node {
>>>>>     @JsonProperty("children") private List<Node> children;
>>>>>     @JsonProperty("text") private String text;}
>>>>>
>>>>> Eventually the tree ends with a Node with an empty list of children.
>>>>>
>>>>> The problem is: serializing a deep tree (say, 50 nodes deep) causes a
>>>>> StackOverflowError on Android devices using the Dalvik runtime since it
>>>>> only has a 32kb stack size.
>>>>>
>>>>> Is there any way to avoid using recursion in Jackson? Is there a more
>>>>> efficient way to represent my POJO? Will migrating to Jackson Jr. help
>>>>> solve my problems? I'm using Jackson 2.7.5.
>>>>>
>>>>> --
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "jackson-user" group.
>>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>>> an email to [email protected].
>>>>> To post to this group, send email to [email protected].
>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>
>>>>
>>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "jackson-user" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to [email protected].
>>> To post to this group, send email to [email protected].
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>> --
> You received this message because you are subscribed to the Google Groups
> "jackson-user" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"jackson-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to