Giter Club home page Giter Club logo

Comments (1)

THEREALWWEFAN231 avatar THEREALWWEFAN231 commented on August 12, 2024

I found another example. That's easier to understand.

This goes in onWindowReady

JavascriptClassDefinition oneClassDef = new JavascriptClassDefinition().name("one").attributes(JavascriptClassAttributes.NO_AUTOMATIC_PROTOTYPE);
			JavascriptClass oneClass = oneClassDef.bake();
			JavascriptObject oneObject = context.makeObject(oneClass);
			globalObject.setProperty("one", oneObject, 0);

			JavascriptClassDefinition twoClassDef = new JavascriptClassDefinition().name("two").parentClass(oneClass).attributes(JavascriptClassAttributes.NO_AUTOMATIC_PROTOTYPE);
			JavascriptClass twoClass = twoClassDef.bake();
			JavascriptObject twoObject = context.makeObject(twoClass);
			oneObject.setProperty("two", twoObject, 0);

			JavascriptClassDefinition threeClassDef = new JavascriptClassDefinition().name("three").parentClass(twoClass).attributes(JavascriptClassAttributes.NO_AUTOMATIC_PROTOTYPE);
			threeClassDef.onCallAsFunction(new JavascriptObjectFunction() {

				@Override
				public JavascriptValue callAsJavascriptFunction(JavascriptContext context, JavascriptObject function, JavascriptObject thisObject, JavascriptValue[] arguments) throws JavascriptInteropException {
					if (true) {
						JavascriptValue string = context.makeString("[{\"x\":-156.5,\"z\":265.5,\"type\":5},{\"x\":-158.5,\"z\":265.5,\"type\":5},{\"x\":-152.5,\"z\":267.5,\"type\":5},{\"x\":-160.5,\"z\":267.5,\"type\":5},{\"x\":-148.5,\"z\":267.5,\"type\":5},{\"x\":-150.5,\"z\":267.5,\"type\":5},{\"x\":-160.5,\"z\":265.5,\"type\":5},{\"x\":-154.5,\"z\":267.5,\"type\":5},{\"x\":-154.5,\"z\":265.5,\"type\":5},{\"x\":-152.5,\"z\":265.5,\"type\":5},{\"x\":-150.5,\"z\":265.5,\"type\":5},{\"x\":-158.5,\"z\":267.5,\"type\":5},{\"x\":-171.31021364279692,\"z\":240.2766290600617,\"type\":0},{\"x\":-162.5,\"z\":265.5,\"type\":5},{\"x\":-156.5,\"z\":267.5,\"type\":5},{\"x\":-148.5,\"z\":265.5,\"type\":5},{\"x\":-155.44999998807907,\"z\":272.44999998807907,\"type\":3},{\"x\":-162.5,\"z\":267.5,\"type\":5},{\"x\":-242.5,\"z\":242.5,\"type\":4}]");
						//string.contextUnlocking();
						return string;
					}
					return context.makeBoolean(false);
				}
			});
			JavascriptClass threeClass = threeClassDef.bake();
			JavascriptObject threeObject = context.makeObject(threeClass);
			twoObject.setProperty("three", threeObject, 0);

this exaggerates the memory leak, calls one.two.three a crap ton and task manager shows memory increasing by about 150MB per second. Looking at VisualVM shows that all objects java side are being correctly garbage collected. There must be something natively that is not releasing some memory?

 function update() {
    for (let index = 0; index < 2500; index++) {
        // @ts-ignore
        let f = one.two.three("");
        // @ts-ignore
        let f1 = one.two.three("");
        // @ts-ignore
        let f2 = one.two.three("");
      }
  }

 function animationFrame() {
    update();
    requestAnimationFrame(animationFrame);
  }
  requestAnimationFrame(animationFrame);

from ultralight-java.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.