RadaeePDF.com :: Topic: Maximum open Documents? 150? (1/2)
Welcome, Guest
Username: Password: Remember me

Signin/Signup with:

Questions about Android development and PDF
  • Page:
  • 1
  • 2

TOPIC: Maximum open Documents? 150?

Maximum open Documents? 150? 2 years 11 months ago #7465

  • apait
  • apait's Avatar
  • OFFLINE
  • Junior Boarder
  • Posts: 36
  • Karma: 0
Hi,
this is rather time-sensitive...

Is there a leak or restriction in your library for opening a bigger amount of documents?

I tested it with pdfs and with images (loaded into an empty pdf).
Everytime it reaches 150 i've got the EMFILE-Exception "Too Many Files opened"

Example:
Load 200 bitmaps in 200 documents. crashes at 150.
final int TESTSIZE = 200;
for(int i = 0; i < TESTSIZE; i++) {
	Document doc = new Document();
	doc.Create(tempPdf);
	doc.SetCache(cache);
	
	Page page = doc.NewPage(0, 200, 200);
	
	PageContent content = new PageContent();
	content.Create();
	
	//set alpha for both fill and stroke
	DocGState dgs = doc.NewGState();
	dgs.SetFillAlpha(0x80);//set alpha value to 0.5
	dgs.SetStrokeAlpha(0x80);//set alpha value to 0.5
	ResGState rgs = page.AddResGState(dgs);
	content.GSSet(rgs);
	
	//write a bitmap
	content.GSSave();
	dgs = doc.NewGState();
	dgs.SetFillAlpha(255);//set alpha value to 1
	dgs.SetStrokeAlpha(255);//set alpha value to 1
	rgs = page.AddResGState(dgs);
	content.GSSet(rgs);
	
	
	Bitmap bmp = Bitmap.createBitmap(300, 600, Config.ARGB_8888);//must be ARGB_8888
	Bitmap bit=BitmapFactory.decodeFile(directoryPlusThumbnail);
	bmp = bit;
	
	DocImage dimg = doc.NewImage(bmp, true);
	bmp.recycle();
	ResImage rimg = page.AddResImage(dimg);
	Matrix mat = new Matrix( 200, 200, 0, 0 );
	
	content.GSSetMatrix(mat);
	mat.Destroy();
	content.DrawImage(rimg);
	content.GSRestore();
	
	page.AddContent(content, true);
	content.Destroy();
	
	page.Close();
}
The administrator has disabled public write access.

Maximum open Documents? 150? 2 years 11 months ago #7466

  • apait
  • apait's Avatar
  • OFFLINE
  • Junior Boarder
  • Posts: 36
  • Karma: 0
i am using the last version of your library...
The administrator has disabled public write access.

Maximum open Documents? 150? 2 years 11 months ago #7469

  • nermeen
  • nermeen's Avatar
  • OFFLINE
  • Moderator
  • Posts: 683
  • Thank you received: 40
  • Karma: 18
Do you close the doc object?
m_doc.Save();
m_doc.Close();
m_doc = null;
The administrator has disabled public write access.

Maximum open Documents? 150? 2 years 11 months ago #7470

  • apait
  • apait's Avatar
  • OFFLINE
  • Junior Boarder
  • Posts: 36
  • Karma: 0
well, i would close it, when leaving the activity, of course.
but i can't close it while displaying the documents.
The administrator has disabled public write access.

Maximum open Documents? 150? 2 years 11 months ago #7471

  • radaee
  • radaee's Avatar
  • OFFLINE
  • Moderator
  • Posts: 825
  • Thank you received: 10
  • Karma: 43
in your test codes, you opened 200 documents and not close it.
The administrator has disabled public write access.

Maximum open Documents? 150? 2 years 11 months ago #7472

  • apait
  • apait's Avatar
  • OFFLINE
  • Junior Boarder
  • Posts: 36
  • Karma: 0
i know. why should i open a document and close it rightafter?
that makes no sense, then i would not be able to display it...

(like i said, i'm recyling all the documents in my ondestroy()... but thats not the point).

we've got a viewpager. for every view, we got a single pdfreadercontroller with a document. everything works fine until the underlying document-array exceeds 150 documents. --> to many files open-exception

my example should just show you, that maybe it has something to do with not-closed-sockets/streams in your library ... ?
i figure you're closing everything on document.close(), but at the same time: you can't call document.close before exiting the activity.

same goes using PDFFileStream ...
it's not possible to open more than 150 docs.
The administrator has disabled public write access.
  • Page:
  • 1
  • 2
Powered by Kunena Forum