×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Registered User
    Join Date
    Oct 2004
    Posts
    4

    Questions Not In Forum

    Hello,

    I use these forums all of the time and they are excellent in helping to resolve the many problems a J2ME programmer faces. Up until now I have not had to post any of my own questions as with a bit of time spent searching you can usually find the answer that you are looking for.

    The following questions are ones that from all my searching have not been completely answered and I am wondering if anyone can fully answer them for me.

    I am mainly developing for the series 60 platform so these questions are mainly for this platform:

    1. I use the Nokia UI API to draw transparent polygons in my code all of the time and that is the only external piece of code that I require and apart from that my code is pure java. I was wondering if there is any way of coding your own transparent polygon code and if so which way you would go about it? I require this as I am starting to look at phones that will not support this UI and it would be useful to have a pure java version of my program.

    2. Once I have obfuscated my code using proguard and then packaged it into a jar file it comes to roughly 150k. After then re-compressing it using WINRAR it takes the jar size down a further 20k. This would be a great decrease for me but when I try to run it on an emulator it fails to find any of the resources(i.e. the logo doesnt apear in the startup menu) and when the application is trying to load it says "class not found exception". I realise this must be something to do with the way WINRAR must have compressed the class files and their names etc but the main class file(midlet) still has the same name - it also has not been changed when it was obfuscated. I was wondering if anyone has managed to successfully use WINRAR in this way and if they could point me in the right direction in how to do so as this is a very interesting development for me as heap memory is critical in my program?

    3. There seems to be a lot of conflicting posts regarding whether to use System.gc()'s or Runtime.getRuntime().gc()'s not and also when to use them. What is the difference between the two? Should they be called as much as possible as speed is not a great issue in my program but heap memory is? When is the best time to call them in your program that would free up most heap memory?

    4. Is there a best place to NULL variables in a series 60 application, and if they are NULLED can that space not be used again? If so is this the same accross all different platforms or only series 60?

    5. For heap memory is it better to define a lot of class variables in your code or is it better to keep as many variables local to your class methods as possible?

    6. Finally, has anyone came up with a proper solution to the reading in a textfile bug on series 60 that uses up more heap memory than it should? This would be a great advantage as there are many hard-coded strings in my program and I would like to organise these into textfiles. Is it also possible to create text compression code that would reduce the jar size and wouldnt drastically use up heap memory once it has been loaded in?


    I know there are a lot of questions and that you may not be able to answer them all without having more information about my program, but any advice or answers would be most greatly welcomed - prefferably if they are not conflicting!

    Many Thanks,

    Jon
    Last edited by JAgoika; 2004-10-14 at 13:18.

  2. #2
    Regular Contributor
    Join Date
    Oct 2004
    Posts
    79
    2. I compress my code and resources by winrar (of course, I use zip algorithm with best compress option). This method decrease the size of code for 5%. My midlet is normally worked after that, but I decided to refuse this method, because I am not sure, that all devices will normally work with such jar file.


    5. Local variables use memory only when code where they are visible is running. And class fields use memory even when class have no objects. Also nonstatic fields use memory for each object of this class.

  3. #3
    Registered User
    Join Date
    Oct 2004
    Posts
    4
    5. Does the garbage collector properly clear and free up the space allocated after the local variables are used in the loacal class methods or is it the same problem on the series 60 of when declaring objects (is this relevant to local class variables?) that they can be nulled etc but their space on the heap cannot be used again as it is fragmented, because if this is the case a class variable would be better to be used as the local variable would be redfined and fragmented each time the method has been called. So basically does the series 60 garbage collector properly free up local method variables?

  4. #4
    Regular Contributor
    Join Date
    Oct 2004
    Posts
    79
    JAgoika
    I can't answer exactly about Nokia series 60 devices. But as far as I know garbage collector must free space when the free memory is drawing to a close.
    In any case, the memory is allocated for class field for each created object, and local variable uses memory if code where it places is executed. I think that second way is better.

  5. #5
    Registered User
    Join Date
    Aug 2003
    Posts
    30
    Has anyone got a solution to question number 6? I have heard that dividing the text file into smaller sections reduces the leak size is this the only solution and does it actually work?

  6. #6
    Registered User
    Join Date
    Oct 2004
    Posts
    4
    I dont suppose anyone has any further feedback to give on the above questions as they are hindering the progress of my application and would be really useful if I could have a better idea on any of them,

    Thanks

Posting Permissions

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