Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using a lot of RAM #3

Open
drthinh opened this issue Oct 11, 2020 · 28 comments
Open

Using a lot of RAM #3

drthinh opened this issue Oct 11, 2020 · 28 comments

Comments

@drthinh
Copy link

drthinh commented Oct 11, 2020

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?

@digitalgust
Copy link
Owner

digitalgust commented Oct 11, 2020

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

@digitalgust
Copy link
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

@drthinh
Copy link
Author

drthinh commented Oct 11, 2020

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

@digitalgust
Copy link
Owner

digitalgust commented Oct 11, 2020

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

@drthinh
Copy link
Author

drthinh commented Oct 12, 2020

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!

@digitalgust
Copy link
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.

@drthinh
Copy link
Author

drthinh commented Oct 12, 2020

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

@digitalgust
Copy link
Owner

digitalgust commented Oct 12, 2020

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

@drthinh
Copy link
Author

drthinh commented Oct 12, 2020

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 😀

@digitalgust
Copy link
Owner

menu can't be click bug fixed.

@digitalgust
Copy link
Owner

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

@drthinh
Copy link
Author

drthinh commented Oct 13, 2020

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.

@digitalgust
Copy link
Owner

digitalgust commented Oct 14, 2020

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 .

@drthinh
Copy link
Author

drthinh commented Oct 14, 2020

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.

@digitalgust
Copy link
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.

@drthinh
Copy link
Author

drthinh commented Oct 14, 2020

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 😀

@digitalgust
Copy link
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

@drthinh
Copy link
Author

drthinh commented Oct 14, 2020

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

@digitalgust
Copy link
Owner

clipboard bug fixed , I am solving Vietnam language display issue

@drthinh
Copy link
Author

drthinh commented Oct 15, 2020

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.

@digitalgust
Copy link
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.

@drthinh
Copy link
Author

drthinh commented Oct 17, 2020

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

@digitalgust
Copy link
Owner

https supported.
I am finding a font to support Vietnam

@drthinh
Copy link
Author

drthinh commented Oct 19, 2020

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,...

@digitalgust
Copy link
Owner

update gui jar to support full unicode font glyph.

@drthinh
Copy link
Author

drthinh commented Oct 19, 2020

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

@digitalgust
Copy link
Owner

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

@drthinh
Copy link
Author

drthinh commented Oct 21, 2020

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants