On Mon, Aug 11, 2014 at 3:07 PM, Brian Craft <craft.br...@gmail.com> wrote:

> Two questions, really. I'm running large batch jobs with an agent. The
> jobs may fail in any number of unanticipated ways (due to user input), so I
> do a try/catch in the agent, log any errors, and continue with the next job.
>
> First question: how to deal with OOM (the Xmx limit, not the OS out of
> mem)? The try/catch doesn't appear to help, here. The agent dies, and all
> subsequent jobs never run. Is there some way to prevent or recover from
> this?
>

Once it has happened, I don't think there's much you can do to save the
process. I'd suggest that you figure out where you're improperly managing
memory by throwing a profiler at it.


> I posed this to a long-time java developer, who said I shouldn't be doing
> a blanket try/catch in the first place, because it's likely to result in
> leaked memory (presumably due to badly-coded libs that don't release
> resources on error). His suggestion: let the thread die on error, and
> restart it from a monitoring thread. I'm not sure how this translates to
> clojure agents. If I don't catch the errors, then log the agent error state
> and restart it, is that equivalent? Is this best practice? Seems like
> badly-coded libs could still leak memory this way, if they've stashed a
> reference in any shared state.
>

Agents are not dealing irectly with threads, so unless you are, you don't
need to worry about that. Internally, agents use one of  two
ExecuterServices that to do their work, depending on whether you're calling
send or send-off. These ExecuterServices manage their threads for you, and
will clean them up if they throw an exception.

I think the spirit of that person's advice is to not blindly catch an
exception and do nothing about it. Make sure that you are cleaning up any
resources that your'e using, and do some profiling! Because you question
was so general, it's hard to get into anything specific.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to