pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From John Hewson <j...@jahewson.com>
Subject Re: font cache & thread safe question
Date Thu, 10 Mar 2016 21:21:13 GMT

> On 10 Mar 2016, at 13:02, Stahle, Patrick <patrick.stahle@te.com> wrote:
> 
> I mean that if multiple jvms using PDFBox library set the java environmental variable
for fontcache to the same location and they are all using the same fontcache directory will
there be any issues?

Ok, I see, I thought you were asking about the in-memory font cache. So the on-disk font cache
just stores some metadata about the fonts on the system. Thinking about it, it’s not actually
cross-JVM safe, as PDFBox can write to the cache on in its static initializers. As long as
the fonts on your system don’t change, then you’re safe, as many JVMs instances can read
safely from the cache. But only one JVM can write it.

So, erm, run a single PDFBox instance on a new machine to build the cache first. I suppose
we should think about adding a locking mechanism.

— John

> -----Original Message-----
> From: John Hewson [mailto:john@jahewson.com] 
> Sent: Thursday, March 10, 2016 3:59 PM
> To: users@pdfbox.apache.org
> Subject: Re: font cache & thread safe question
> 
> 
>> On 10 Mar 2016, at 08:09, Stahle, Patrick <patrick.stahle@te.com> wrote:
>> 
>> Hi,
>> 
>> Is the font cache code in pdfbox thread safe? If it is, is it thread safe just for
the jvm or is it thread safe across multiple jvms?
> 
> Yes, it is, because it’s always accessed by FontMapperImpl in a thread safe manner.
I’m not sure what you mean about multiple JVMs, objects can’t be shared across JVMs.
> 
>> Thanks,
>> Patrick
>> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org


Mime
View raw message