• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JPA is expansive solution when memory is critical

 
Syed Saifuddin
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi EveryBody

I hosting service is very critical about memory and I have only 64MB with private tomcat. Is old JDBC way is better in my case or JPA is also recourse saving solution.

if statement and preparedstatement is replace by JPA. comparatively how much is the difference.

Any idea or any words in this is really appreciated.
 
Shailesh Kini
Ranch Hand
Posts: 153
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Syed,

Depends on how you are planning to use it. You could turn off caching or manage caching size as a property in persistence.xml. You could always give a shot at it.

In my opinion with just 64 MB RAM you should not run any kind of app server on it.
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First, JPA does not require an App Server.

But the other points that Shailesh brought up are valid. You do not hvae to cache anything, and the only object that will take really any memeory, besides the loaded data is the Factory class EntityManagerFactory. But that also depends on how many mapped classes you need?

You can definitely use JPA and find it easier to maintain than JDBC in your memory critical situation, but you do have to know how to minimize the JPA footprint well.

Good Luck

Mark
 
Syed Saifuddin
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Shailesh Kini and Mark Spritzler

In my local computer I am running JPA app with tomcat6.

But the the main thing I want to know is how much is the actual difference.

I mean JPA app is twice footprint then plain JDBC. or more


Writing sql statement is difficult for everything but here memory is critical.
 
Shailesh Kini
Ranch Hand
Posts: 153
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Syed,

Please read Mark's reply. As he said it all depends on how many mapped classes you have in your application. If you are using JDBC and mapping the resultset to POJO's then you do not have much difference on memory footprint. If you are just traversing through your result set in your jsp and displaying them you are not creating any additional objects so your memory foot print is small. It also depends on how huge your result set is, how many columns it has etc...

To summarize...
There is not much of a difference if you use JPA or convert your resultset into Collection of POJO's yourself. If you are worried about query parsing... then it is parsed only once and it works exactly the same as JDBC. Only with JDBC you have to write a lot of code.

If you want metrics... Google is your best friend!

Hope this answer's your question.
 
Syed Saifuddin
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank You Shailesh Kini
 
Erik Bengtson
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
simply do not use JPA. It has enormous footprint. Also, you have to consider for each entity class:

-classes are redefined in memory
-metadata has be loaded and hold in memory
-adapter classes for DB
-JPA implementation objects
-db metadata
-garbage collection
-unnecessary fetched objects
-the list goes on...

Just stick to JDBC

Erik Bengtson
http://jpox.org (JPOX is a JDO and JPA implementation)
 
Shailesh Kini
Ranch Hand
Posts: 153
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Eric,

You bring some good arguments to the table for not using JPA in this
scenario. I completely agree with you.

Thanks!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic