Skip to content

Using a lot of RAM #3

Open
Open

Description

@drthinh

I used miniJVM to demostrate a tiny console app 'Hello World' without any GUI library, it spent 35MB RAM only with minimal runtime? Are there any problem with memory model?

Activity

  1. digitalgust commented on Oct 11, 2020

    @digitalgust
    Owner

    Change jvm.h
    #define _JVM_DEBUG_LOG_LEVEL 01
    change 01 to 02 ,You will get the gc detail information.

    Running SpecTest:
    mini_jvm.exe -bootclasspath ../lib/minijvm_rt.jar -cp ../libex/minijvm_test.jar test/SpecTest

    Output:

    [INFO]main thread start
    [JDWP]waiting for jdwp(port:8000) debug client connected...
    test start
    [INFO]thread start 10c75aa00
    [INFO]gc obj: 4200->648   heap : 346732 -> 54060  stop_world: 0  gc:0
    [INFO]gc obj: 648->648   heap : 54060 -> 54060  stop_world: 1  gc:0
    [INFO]gc obj: 648->648   heap : 54060 -> 54060  stop_world: 0  gc:0
    [INFO]gc obj: 648->648   heap : 54060 -> 54060  stop_world: 0  gc:0
    [INFO]thread over 10c75aa00 , spent : 4010
    test end
    [INFO]main thread over 10c235e90 , spent : 4027
    [INFO]garbage clear start
    [INFO]objs size :648
    [INFO]gc obj: 2146->882   heap : 186151 -> 83168  stop_world: 1  gc:0
    [INFO]gc obj: 882->882   heap : 83168 -> 83168  stop_world: 0  gc:0
    [INFO]gc obj: 882->64   heap : 83168 -> 20824  stop_world: 0  gc:0
    [INFO]gc obj: 64->64   heap : 20824 -> 20824  stop_world: 0  gc:0
    [INFO]gc obj: 64->0   heap : 20824 -> 0  stop_world: 0  gc:0
    [INFO]gc obj: 0->0   heap : 0 -> 0  stop_world: 0  gc:0
    [INFO]objs size :0
    [INFO]jvm destoried heap size = 0
    
    Process finished with exit code 0
    
  2. digitalgust commented on Oct 11, 2020

    @digitalgust
    Owner

    miniJVM is using ltalloc to allocate memory, system allocated memory is more than jvm usage, comment the line in d_type.h to disable ltalloc, will get the more accurate memory.
    //#define MEM_ALLOC_LTALLOC

  3. drthinh commented on Oct 11, 2020

    @drthinh
    Author

    Thank you very much, after disable ltalloc, it spends only 12MB RAM, I feel much better. I don't know why ltalloc was used and what will happend when turn it off. Because of lacking document, I don't know how to program with the runtime, especially java.net library, it doesn't have API to connect internet neither https protocol. I hope you would add more features and documents for this project, I really love it, thank you

  4. digitalgust commented on Oct 11, 2020

    @digitalgust
    Owner

    ltalloc is a little faster than c malloc on iOS/macOS/win, but equals to Linux/Android, but it waste memory than c malloc. Https on the way, I am construct it . There are few documents now , plan to write it.
    now please clone the example project :
    https://github.com/digitalgust/BiBiX

  5. drthinh commented on Oct 12, 2020

    @drthinh
    Author

    I have update the library again, it runs well :) but I have a problem with start GUI app when window fullscreen, I can't click the buttons again, may be because of the change of coordinate . Btw, could you update Android binary version. Thanks!

  6. digitalgust commented on Oct 12, 2020

    @digitalgust
    Owner

    The windows app resize to fullscreen , it works in my win10x64, I don't know what happen in your situation, do you have more information about this.
    I updated android app.

  7. drthinh commented on Oct 12, 2020

    @drthinh
    Author

    Everything was ok until I sign in BiBiX, after that I resized the window to fullscreen I couldnt click three bottom buttons.
    The new apk cant be installed with Android version 10, it was blocked by Google Protect because of unknow programmer ID.
    Screenshot_2020-10-12-17-02-13-259_com android vending

  8. digitalgust commented on Oct 12, 2020

    @digitalgust
    Owner

    android submited a debug version, plz try it .
    bibix menu could not click , let me check what happened .

  9. drthinh commented on Oct 12, 2020

    @drthinh
    Author

    I tried to install that apk many times, but it still be blocked by Google Protect. I will try to build another ones. Thank you, hope you could find the problem with bibix app 😀

  10. digitalgust commented on Oct 13, 2020

    @digitalgust
    Owner

    menu can't be click bug fixed.

  11. digitalgust commented on Oct 13, 2020

    @digitalgust
    Owner

    android binary , may be you can build it yourself , Android Studio open project
    miniJVM/mobile/androidapp
    build and run .

  12. drthinh commented on Oct 13, 2020

    @drthinh
    Author

    All above issues are solved 😁. Btw, when I compare speed, RAM and CPU usage, the mini_jvm takes 150-200% slower, more resource especially CPU used than JVM in same console tests: calculate primes < 1000, Fibonacci,... Could you have a solution for this issue? Thank you.

  13. digitalgust commented on Oct 14, 2020

    @digitalgust
    Owner

    oracle jvm or openjdk jvm did lots of optimizations for jit , the minijvm implemented jit ,but few of static analysts and optimizations ,so the minijvm have worse performance , minijvm developed for iOS and android mainly, Only provide a same development and running environment for pc, And the iOS platform does not allow applications to run in jit mode. alternately ,there is a java2c ( https://github.com/digitalgust/java2c ) project can convert minijvm jar to c source , the performance is very closely to oracle jvm .

  14. drthinh commented on Oct 14, 2020

    @drthinh
    Author

    Your project have some similar plans like corona mobile sdk/solar2D which use Lua to program in Android/iOs/desktop (embedded source code in apk - I don't like that) or Codename One (closed source and limited file compiled), but I think your solution is better because of Java language and native high performance graphic lib for mobile. But I would like to hearing from your desktop solution like native Windows GUI (awt implementation..).
    Btw BiBiX (Windows 10x64) cant type Unicode characters.
    Thanks.

  15. digitalgust commented on Oct 14, 2020

    @digitalgust
    Owner

    minijvm app can update jar file anytime , then need restart app only.
    there are no plan to develop a new GUI for windows, like awt , but there are some of open source project like OpenAWT and more ,to adapt to minijvm is not difficult , minijvm gui lib support Nanovg api etc.
    the recent plan to :
    implement https
    dump vm memory like virtualvm
    hard limit vm memory to specified value
    fix bugs and optimize gui system.

  16. drthinh commented on Oct 14, 2020

    @drthinh
    Author

    Because of the libgui support GUI controls like TextBox, Button, ListBox,...but in desktop I still can't type unicode, or copy from clipboard...so I must find another solution. I will choose one of your suggestions, could you write some tips for using minijvm native interface?.
    I hope you soon add https protocol 😀

  17. digitalgust commented on Oct 14, 2020

    @digitalgust
    Owner

    can't type unicode, can't using clipboard, these are issues, i will repair it, can u shows more information about this , because i can type chinese in win platforms, gui support clipboard too

  18. drthinh commented on Oct 14, 2020

    @drthinh
    Author

    I'm using Unikey, but instead of display "trần văn dũng" it showed "trn vn dng", unicode characters "ầ ă ũ" weren't appeared.
    First startup screen, the textbox "Download app from website" doesnt show context menu Paste at right click nor Ctrl + V
    When run BiBiX, have context menu when right click but nothing show in textbox login
    I copy Chinese characters to textbox but it still show nothing

  19. digitalgust commented on Oct 15, 2020

    @digitalgust
    Owner

    clipboard bug fixed , I am solving Vietnam language display issue

  20. drthinh commented on Oct 15, 2020

    @drthinh
    Author

    clipboard is now ok. But I still can't paste Unicode or type Unicode to textbox. The textbox have Ctrl + V but dont have Ctrl + Z?
    btw, it takes more resource than the previous, 99MB RAM when startup.

  21. digitalgust commented on Oct 16, 2020

    @digitalgust
    Owner

    ctrl+z can be add, it 's not the fixed heap using every times, it related with gc period. if the gc work per 30s, it would be more heap use , so i plan to limit the heap to specify value.

  22. drthinh commented on Oct 17, 2020

    @drthinh
    Author

    Oh, I'm looking forward to your next mini_jvm version

  23. digitalgust commented on Oct 19, 2020

    @digitalgust
    Owner

    https supported.
    I am finding a font to support Vietnam

  24. drthinh commented on Oct 19, 2020

    @drthinh
    Author

    I have tried with your previous https.c/https.h - mbedtls wrapper (for Mac but with little changes to compile in Windows), it didn't run, but now, your lastest https library run smooth. I expected it so much.
    All popular unicode fonts support Vietnam characters, examples: Times New Roman, Consolas, Courier New, Arial,...

  25. digitalgust commented on Oct 19, 2020

    @digitalgust
    Owner

    update gui jar to support full unicode font glyph.

  26. drthinh commented on Oct 19, 2020

    @drthinh
    Author

    Unicode is ok now!
    I hope can use mouse to select text (now only can use right mouse -> select text) and Ctrl +Z
    BTW, the last BiBiX crashed when enter random login text, can't go back/exit
    error

  27. digitalgust commented on Oct 20, 2020

    @digitalgust
    Owner

    update textfield to support hotkey , how the bib crushed , could you delete app and redownload it try again.

  28. drthinh commented on Oct 21, 2020

    @drthinh
    Author

    I deleted app and downloaded the lastest binaries, it's now OK, very smooth, only one downside it took 120MB RAM on startup

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions