Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5947549
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T16:58:47+00:00 2026-05-22T16:58:47+00:00

Is JS_malloc only used to allocate memory for javascript types in Spidermonkey? If I

  • 0

Is JS_malloc only used to allocate memory for javascript types in Spidermonkey?

If I need to allocate memory for a third-party datatype (not a JSObject or similar), is it ok to use malloc?

What are the differences between JS_malloc and C malloc?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T16:58:47+00:00Added an answer on May 22, 2026 at 4:58 pm

    JS_malloc is just there because it is guaranteed to use the same allocator as the Spidermonkey itself does, which may not be the same allocator as malloc in your code. In particular some popular OSes (e.g. Windows) support separate heaps with separate allocators per shared library; if you’re dynamically linking to Spidermonkey then calling Spidermonkey’s free on memory you malloc in your code would crash.

    So if you’re going to deallocate the object yourself, you can use either malloc/free or JS_malloc/JS_free as long as you’re consistent. It doesn’t matter much which one you use, unless you have specific requirements on which DLL’s heap you want it to live in (e.g. you plan to unload the Spidermonkey DLL at some point while some of these objects are live).

    If you’re doing the allocation but expect Spidermonkey to do the deallocation, you need to use JS_malloc.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Scroll.js is used for #bird block, which follows the page scrolling. The main problem
jquery.js source code is not being recognised by browser using my page.html served by
My js code does POST order.php?order[]=1&order[]=2&order[]=3&order[]=4&order[]=5&&action=update How to reverse it to order.php?order[]=5&order[]=4&order[]=3&order[]=2&order[]=1&&action=update ? JavaScript:
This js-code works in safari on my pc, but not on a ipod touch
MicrosoftMvcJQueryValidation.js is used by ASP.NET MVC 2 for client side validation. Having problems with
I'm a JS beginner. My question is do we always need to use a
JS is not working properly. I don't know why. can anyone help me? Here
my js file loads on all pages. Some functions are meant to run only
@ref prototype.js I have seen this Prototype.js ajax syntax used everywhere. However I have
JS function loadXml() { $.ajax({ type: 'get', url: 'test.xml', dataType: 'xml', success: function(output) {

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.