Is there a way to create a TypedArray from an ArrayBuffer without using new keyword in Javascript?Does `postMessage` or yielding to the event loop or similar sync shared memory?Create GUID / UUID in JavaScript?What is the most efficient way to deep clone an object in JavaScript?How do I remove a property from a JavaScript object?Creating multiline strings in JavaScriptHow to extend an existing JavaScript array with another array, without creating a new arrayWhat is the 'new' keyword in JavaScript?Open a URL in a new tab (and not a new window) using JavaScriptHow do I remove a particular element from an array in JavaScript?How can I add new array elements at the beginning of an array in Javascript?Correct way to transfer TypedArrays?

Colloquialism for “see you later”

1980s live-action movie where individually-coloured nations on clouds fight

Is it legal for a bar bouncer to confiscate a fake ID

Russian word for a male zebra

Why we don’t make use of the t-distribution for constructing a confidence interval for a proportion?

Did Milano or Benatar approve or comment on their namesake MCU ships?

CROSS APPLY produces outer join

Active low-pass filters --- good to what frequencies?

Is a lack of character descriptions a problem?

Importance of Building Credit Score?

Overlapping String-Blocks

How can I end combat quickly when the outcome is inevitable?

Is it expected that a reader will skip parts of what you write?

How did old MS-DOS games utilize various graphic cards?

Group Integers by Originality

With Ubuntu 18.04, how can I have a hot corner that locks the computer?

How do I prevent employees from either switching to competitors or opening their own business?

Alternate way of computing the probability of being dealt a 13 card hand with 3 kings given that you have been dealt 2 kings

How is water heavier than petrol, even though its molecular weight is less than petrol?

Why can my keyboard only digest 6 keypresses at a time?

What ways have you found to get edits from non-LaTeX users?

Soft question: Examples where lack of mathematical rigour cause security breaches?

Rebus with 20 song titles

Fixing obscure 8080 emulator bug?



Is there a way to create a TypedArray from an ArrayBuffer without using new keyword in Javascript?


Does `postMessage` or yielding to the event loop or similar sync shared memory?Create GUID / UUID in JavaScript?What is the most efficient way to deep clone an object in JavaScript?How do I remove a property from a JavaScript object?Creating multiline strings in JavaScriptHow to extend an existing JavaScript array with another array, without creating a new arrayWhat is the 'new' keyword in JavaScript?Open a URL in a new tab (and not a new window) using JavaScriptHow do I remove a particular element from an array in JavaScript?How can I add new array elements at the beginning of an array in Javascript?Correct way to transfer TypedArrays?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








2















I am using transferables to communicate between the main thread and the worker. I realized the communcation creates GC activity because after receiving the buffer, I'm converting the buffer to a typed array using the new keyword:



var ary = new Float32Array(buffer);


Is there a way to re-use a TypedArray or getting a view of a buffer without creating GC activity?










share|improve this question






















  • i doubt there is a way

    – GottZ
    Mar 24 at 18:02

















2















I am using transferables to communicate between the main thread and the worker. I realized the communcation creates GC activity because after receiving the buffer, I'm converting the buffer to a typed array using the new keyword:



var ary = new Float32Array(buffer);


Is there a way to re-use a TypedArray or getting a view of a buffer without creating GC activity?










share|improve this question






















  • i doubt there is a way

    – GottZ
    Mar 24 at 18:02













2












2








2








I am using transferables to communicate between the main thread and the worker. I realized the communcation creates GC activity because after receiving the buffer, I'm converting the buffer to a typed array using the new keyword:



var ary = new Float32Array(buffer);


Is there a way to re-use a TypedArray or getting a view of a buffer without creating GC activity?










share|improve this question














I am using transferables to communicate between the main thread and the worker. I realized the communcation creates GC activity because after receiving the buffer, I'm converting the buffer to a typed array using the new keyword:



var ary = new Float32Array(buffer);


Is there a way to re-use a TypedArray or getting a view of a buffer without creating GC activity?







javascript web-worker transferable






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 24 at 17:59









Oğuz EroğluOğuz Eroğlu

718




718












  • i doubt there is a way

    – GottZ
    Mar 24 at 18:02

















  • i doubt there is a way

    – GottZ
    Mar 24 at 18:02
















i doubt there is a way

– GottZ
Mar 24 at 18:02





i doubt there is a way

– GottZ
Mar 24 at 18:02












1 Answer
1






active

oldest

votes


















1














I don't think there is, no. ArrayBuffer is pretty much a black box without a typed array or DataView to look into it, and you can't change the buffer on an existing typed array or DataView.



On platforms that support it, you can create a SharedArrayBuffer that both the main and worker thread have access to, which wouldn't have the GC problem since each side would reuse its wrapper array. Just make sure you gatepost access to it via postMessage or Atomics (more about that in this question's answer).



But sadly, most browsers disabled SharedArrayBuffer in response to Spectre, and the last I checked only Chrome has re-enabled it (on platforms where its site isolation feature is enabled).






share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55326814%2fis-there-a-way-to-create-a-typedarray-from-an-arraybuffer-without-using-new-keyw%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    I don't think there is, no. ArrayBuffer is pretty much a black box without a typed array or DataView to look into it, and you can't change the buffer on an existing typed array or DataView.



    On platforms that support it, you can create a SharedArrayBuffer that both the main and worker thread have access to, which wouldn't have the GC problem since each side would reuse its wrapper array. Just make sure you gatepost access to it via postMessage or Atomics (more about that in this question's answer).



    But sadly, most browsers disabled SharedArrayBuffer in response to Spectre, and the last I checked only Chrome has re-enabled it (on platforms where its site isolation feature is enabled).






    share|improve this answer



























      1














      I don't think there is, no. ArrayBuffer is pretty much a black box without a typed array or DataView to look into it, and you can't change the buffer on an existing typed array or DataView.



      On platforms that support it, you can create a SharedArrayBuffer that both the main and worker thread have access to, which wouldn't have the GC problem since each side would reuse its wrapper array. Just make sure you gatepost access to it via postMessage or Atomics (more about that in this question's answer).



      But sadly, most browsers disabled SharedArrayBuffer in response to Spectre, and the last I checked only Chrome has re-enabled it (on platforms where its site isolation feature is enabled).






      share|improve this answer

























        1












        1








        1







        I don't think there is, no. ArrayBuffer is pretty much a black box without a typed array or DataView to look into it, and you can't change the buffer on an existing typed array or DataView.



        On platforms that support it, you can create a SharedArrayBuffer that both the main and worker thread have access to, which wouldn't have the GC problem since each side would reuse its wrapper array. Just make sure you gatepost access to it via postMessage or Atomics (more about that in this question's answer).



        But sadly, most browsers disabled SharedArrayBuffer in response to Spectre, and the last I checked only Chrome has re-enabled it (on platforms where its site isolation feature is enabled).






        share|improve this answer













        I don't think there is, no. ArrayBuffer is pretty much a black box without a typed array or DataView to look into it, and you can't change the buffer on an existing typed array or DataView.



        On platforms that support it, you can create a SharedArrayBuffer that both the main and worker thread have access to, which wouldn't have the GC problem since each side would reuse its wrapper array. Just make sure you gatepost access to it via postMessage or Atomics (more about that in this question's answer).



        But sadly, most browsers disabled SharedArrayBuffer in response to Spectre, and the last I checked only Chrome has re-enabled it (on platforms where its site isolation feature is enabled).







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 24 at 18:07









        T.J. CrowderT.J. Crowder

        713k12612741362




        713k12612741362





























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55326814%2fis-there-a-way-to-create-a-typedarray-from-an-arraybuffer-without-using-new-keyw%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

            Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

            Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript