×

Discussion Board

Results 1 to 14 of 14
  1. #1
    Registered User
    Join Date
    Nov 2009
    Posts
    188

    Memory issues with large no of classes!

    Hi All,

    I am developing an application in j2me for Nokia Series 60 devices using MIDP-2.0 and CLDC-1.1.
    In two classes I am having more than 3000 lines of code.So I am thinking to split into multiple classes.
    But I do not know how it will affect in terms of memory.Because there are allready more than 45 classes in my application and if I am going to split it based on the functionality it will increase to another 12 to 15 classes.
    If any body have any idea wheather it is correct to split into multiple classes or not.
    Please guide me....


    Thanks & Regards,
    Ajit

  2. #2
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: Memory issues with large no of classes!

    Do not be afraid of large classes if large classes make sense. It is a myth that small classes or small methods are "better". There is no evidence to support this idea.

    For newer S60 devices, 60 classes is not a problem.

    Simply, the right number of classes is... the right number of classes! The most important point is that the program should make sense!!

    Graham.

  3. #3
    Registered User
    Join Date
    Nov 2009
    Posts
    188

    Re: Memory issues with large no of classes!

    Thanks Grahm for your reply!!!

    Sorry for the inconvenience!!!

    By mistake I have wrote as Series 60 devices but actuallt I am developing Nokia Series 40 devices 3rd edition devices.
    So what ever you have replied is it ok for Series 40 devices 3rd edition devices?

    By doing all functionality in a single class is very difficult maintanance in future.
    And afaik each time when ever we are going to create an object of larger class it will be heavy weighted object and affect in terms of memory.If I split into multiple classes then this heavy weighted object will not be there and I can save some heap memory.

    Let me correct if I am wrong.
    Please guide me...

    Thanks & Regards,
    Ajit

  4. #4
    Registered User
    Join Date
    Oct 2009
    Location
    Noida
    Posts
    941

    Re: Memory issues with large no of classes!

    I am having more than 3000 lines of code in a class
    It should be good to divide this into multiple classes, to reduce its load from heap and make your code more readable/maintainable, even for S40 3rd edition having 45 or 60 classes will not make much difference.
    Thanks,
    Ekta

  5. #5
    Registered User
    Join Date
    Nov 2009
    Posts
    188

    Re: Memory issues with large no of classes!

    Thank you very much Ekta!!!

    Even I was thinking the same but was not sure about the memory issues.


    Thanks & Regards,
    Ajit

  6. #6
    Registered User
    Join Date
    Oct 2009
    Location
    Noida
    Posts
    941

    Re: Memory issues with large no of classes!

    Be careful of JAR size restrictions, S40 3rd ed on most devices it would be like 1MB.

    Having large number of files may increase the JAR size a bit extra load of around 1kb (after obfuscation) is added per new class.
    Thanks,
    Ekta

  7. #7
    Registered User
    Join Date
    Nov 2009
    Posts
    188

    Re: Memory issues with large no of classes!

    Oh is it?

    Now the JAR size is about 300 kb after obfuscation and 820 kb without obfuscation with around 45 to 50 classes.
    After splitting there will be 65 - 70 classes.
    So how it will affect to my JAR size after splitting.
    From the JAR size point of view is it right to split or not ?

    Please guide me...

    Thanks & Regards,
    Ajit
    Last edited by ajitkumar26; 2010-07-06 at 08:16.

  8. #8
    Nokia Developer Champion
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    3,073

    Re: Memory issues with large no of classes!

    Yes, it will be right to split for now. adding 20 files to the JAR it will max impact the obfuscated JAR size by 10 to 15kb... which is OK as your Jar is just 300kb for now.
    thanks,
    ~Amitabh
    (Champion of the Month -Aug'13)
    Follow me on my blog for Innovative Mobile Apps

  9. #9
    Registered User
    Join Date
    Nov 2009
    Posts
    188

    Re: Memory issues with large no of classes!

    Thank you Amit for your reply!
    I have a doubt regarding the increase in JAR size when increasing the no of files.

    Is there any constraints to increasing JAR size per class?
    In what basis it is increasing means you have mentioned that adding 20 files it will max impact the obfuscated JAR size by 10 to 15kb.
    So irrespective of the indivisual file size it will increase or is it depends on the file size also.

    Please clarify my doubts...or provide me some useful link from where I will get the information regarding my doubt.



    Thanks & Regards,
    Ajit
    Last edited by ajitkumar26; 2010-07-07 at 14:07.

  10. #10
    Registered User
    Join Date
    Nov 2009
    Posts
    188

    Re: Memory issues with large no of classes!

    Hi All,

    Can any body clarify my below posted doubt please..........



    Thanks & Regards,
    Ajit

  11. #11
    Regular Contributor
    Join Date
    Jul 2008
    Location
    Faridabad(Delhi NCR)
    Posts
    343

    Re: Memory issues with large no of classes!

    HI ajit

    There is no problem in spliting class because the main jar size depends on the resources not only the class and there is no problem if you write 3000 line code in one classes but the main thing is how you implemented the . be carefully about useless creation of object and please release them if you don't want to loose.and you can split your class but please take care that these classes working fine
    Anshu Chauhan
    J2me Developer

  12. #12
    Registered User
    Join Date
    Nov 2009
    Posts
    188

    Re: Memory issues with large no of classes!

    Hi Anshu,

    Thanks for your reply!
    JAR size depends on the resources that I Know.
    My doubt is Suppose I have two classes of one having 5000 lines of code and another having 200 lines of code.
    So how it will impact on the JAR size indivisually.
    Can you please clarify this...

    Thanks & Regards,
    Ajit

  13. #13
    Regular Contributor
    Join Date
    Jul 2008
    Location
    Faridabad(Delhi NCR)
    Posts
    343

    Re: Memory issues with large no of classes!

    Hey Please check this link may be this will give you correct answer

    http://proguard.sourceforge.net/index.html#/FAQ.html
    Anshu Chauhan
    J2me Developer

  14. #14
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: Memory issues with large no of classes!

    If you have more classes, your JAR size is likely to increase. You will add at least 150 bytes for every class, but it could be much more. Developers who target devices with very tight JAR size constraints often develop deliberately to a small number of classes, or use class-merging technologies, to reduce the JAR size.

    Graham.

Similar Threads

  1. Out of Memory Error uploading large files
    By matuki in forum Mobile Java Networking & Messaging & Security
    Replies: 2
    Last Post: 2009-08-21, 19:27
  2. large amount of memory
    By Digish in forum Symbian
    Replies: 5
    Last Post: 2008-07-15, 12:37
  3. Large(complex) gif display and memory usage
    By WhoKnows in forum Symbian
    Replies: 10
    Last Post: 2008-05-08, 13:11
  4. Large polymorphic DLLs and memory usage
    By ralph.spada in forum Symbian
    Replies: 3
    Last Post: 2007-08-18, 18:42
  5. s40 - memory required for loading the classes
    By space2 in forum Mobile Java General
    Replies: 2
    Last Post: 2005-07-12, 14:07

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •