Hi.  In general, the memory reported by the profile will be less than than
the memory allocated by the OS.  You can see this Stack Overflow article
<https://stackoverflow.com/questions/24863164/how-to-analyze-golang-memory>
for some explanation.

More specifically, I see that your sample program is converting the
underlying MongoDB data to a map form (bson.M).  There are ways to work
with documents as raw bytes, which may allow you to be more efficient with
total allocated memory. This isn't the right forum for that discussion, but
I encourage you to post to the mongodb-go-driver
<https://groups.google.com/forum/#!forum/mongodb-go-driver> mailing list
for more assistance.

Thanks for using MongoDB with Go!

Regards,
David

On Wed, Feb 27, 2019 at 4:26 AM Lee Rick <blade2i...@gmail.com> wrote:

> go1.12
>
> i have 89936 records in mongodb, when i write a go program to load data
> and profile it, i find it wrong
> the size of 89936 records is about 85MB,  go profile it use 100MB, and use
> linux command top, the res is about 300MB
> go program shoud use 100MB memory, but it use 300MB
>
> my go code in  attachment
>
> anyone can tell me how reduce memory to 100MB
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to