pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tilman Hausherr <THaush...@t-online.de>
Subject Re: Mutable COSInteger
Date Sat, 14 Feb 2015 12:03:29 GMT
Am 13.02.2015 um 12:48 schrieb Andrea Vacondio:
> Hi,
> I was looking at the COSInteger and I have a couple of questions.
> I noticed that it caches instances between in -100 and 265.
> My first question is why those limits and not cache everything... perhaps
> with Soft or Weak values? I made a very rough test using a Map to cache all
> the COSInteger and I loaded the 32MB pdf_reference_1-7.pdf, it saved a
> couple of MB of memory and about 130k COSInteger instances, not much but
> still... Is there any reason I'm missing for those limits?
> Second question. They are cached and they are mutable so this:
>      {
>          COSInteger cosint = COSInteger.get(10);
>          cosint.setValue(50);
>          //lets move to a totally unrelated part of my software
>          System.out.println(COSInteger.get(10));
>      }
> prints COS{50} so basically I ask for a 10 and get a 50, isn't it weird
> (and error prone)? ... or the way around, I call cosint.setValue(50) at
> some point in the software and that makes it a 50 everywhere I used
> COSInteger.get(10).
> That's of course also true for the other mutable attributes setDirect and
> setNeedToBeUpdate.
> Thoughts?
that you're fearless and like to travel to the dark alleys of PDFBox?

I've opened

About what to do? First thought: remove setValue(). I thought that a red 
light would go on in the IDE, but no. However that doesn't solve the 
problem about setDirect and setNeedToBeUpdate.


PS: These kind of discussions better be in the dev list.


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

View raw message